Jump to content

Session Expiry/Times


Mutley

Recommended Posts

I've simply set some sessions....

 

		$_SESSION['LoggedIn'] = 1;
	$_SESSION['UserID'] = $row["UserID"];

 

They don't seem to last very long, usually when I close my browser and go back on later, they'll expire. I want them to last permanently unless the user logs out.

 

How do I do this?

 

Thanks in advance.

Link to comment
Share on other sites

By default, session variables last one browser session (the session cookie lifetime is set to zero so that the cookie is only held in the browser's cookie cache, which is deleted when the browser is closed.)

 

To make a session last longer requires that you both extend the session cookie lifetime setting and the session garbage collection maxlifetime setting. If you are on a shared web server you must also make the session save path point to a 'private' folder within your account's folder tree so that only your session settings affect your sessions.

 

The normal way this is accomplished is to use a regular cookie to just identify the visitor (using a unique and hard to guess and hard to produce value) and his logged in status is kept in your user table in the database.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.