Current location: Hot Scripts Forums » Programming Languages » PHP » PHP Sessions problem


PHP Sessions problem

Reply
  #1 (permalink)  
Old 06-26-04, 11:39 AM
dannyallen dannyallen is offline
Newbie Coder
 
Join Date: Jun 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy PHP Sessions problem

For some reason, I cannot get my PHP sessions to last for at least 10 days. The longest I can get it to work is around a half hour, then if you don't visit the site, your session is just deleted. You have to login in before the session starts, so here is my code:

Code:
	
if ($uncrypted == $result[password]) {
	session_cache_expire('8640000');
	session_set_cookie_params('8640000');
	session_start();
	$_SESSION['username'] = $HTTP_POST_VARS[username];
	$_SESSION['uid'] = $result[uid];
	$_SESSION['time'] = time(); 

(some more code like inserting session to db etc)
You see, I tried to make the session expire after '8640000' in two ways. Neither seem to work. At the top of each page that I want the sessions to stay on, I have:

Code:
session_cache_expire('8640000');
session_set_cookie_params('8640000');
session_start();
Is there anyway so that a session is kept throughout an entire script, with all the variables registered, for 10 days?

Also, I have thought about using ?PHPSESSID=blahblahetc in links. Will this fix my problem for keeping the sessions if I have that in the URL of ever single page? And if that does fix the problem, is there anyway to hide that ?PHPSESSID=safdkjsaf212412 from the top of the page and still keep the session for 10+ days with all of the variables?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 06-26-04, 11:43 AM
sufyan sufyan is offline
Newbie Coder
 
Join Date: Jun 2003
Location: Melbourne, AU
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
You might want to try Cookies instead of sessions:

http://au3.php.net/manual/en/function.setcookie.php

Sessions usually expire when the user terminates their session with the server (ie. closes their browser)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
can someone help with htaccess and php problem tigherrdk PHP 6 03-09-09 03:28 AM
Can anyone help me ? (problem using php variables in html db insert code) chronic_ PHP 2 06-13-04 12:19 PM
php in linux problem usman PHP 6 05-15-04 12:57 PM
PHP sessions mno PHP 4 11-29-03 04:15 AM
PHP & sessions, why won't it work? TinnyFusion PHP 1 10-04-03 02:51 PM


All times are GMT -5. The time now is 12:15 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.