Jump to content

sessions not expiring


Recommended Posts

hey guys,

 

i recently changed my session save directory to "/home/jacko/LocalHost/sess" using htaccess, but now ive noticed that sessions dont seem to be expiring, i still have sessions in the folder from testing my website yesterday. Was i incorrect in thinking that sessions are supposed to expire on exit?

 

below is a shot of my php.ini... can anyone see any problems with my setup?..

iekthf.png

 

thanks

Link to comment
Share on other sites

unless anyone can suggest a better way, ill have to go with the suggested answer from this post i just found:

http://stackoverflow.com/questions/520237/how-do-i-expire-a-php-session-after-30-minutes

 

...which basically says to record a time stamp (and update it on user activity), then if there hasn't been any activity for X amount of time, then unset/destroy the session

Link to comment
Share on other sites

now ive found another problem..

after doing as the post on stackoverflow.com suggests, i found that when using session_destroy() or unset($_SESSION['blah']) all they do is remove all the data inside the session, but leave the empty session file behind... how do i remove the file too?

...otherwise im going to have a folder full of old, empty files

 

will i just have to use

unlink('/home/jacko/LocalHost/sess/sess_[sESSION ID HERE]')

..or is there a php session setting for removing empty sessions?

 

 

thanks

Link to comment
Share on other sites

Old session data files are removed by session garbage collection, which runs randomly based on session.gc_probability and session.gc_divisor when you execute session_start() statements.

 

Rather that rely on incomplete bits and pieces of information you find posted around on the Internet, you should read the relevant section of the php.net documentation to find out the full story for whatever you are attempting to do with php.

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.