Page 1 of 1

Sessions not getting deleted

Posted: Fri Dec 12, 2003 6:33 pm
by Chambrln
I just took a look at my sessiondata folder today and noticed there were over 460,000 session files in the folder. I also noticed that the permissions were setup incorrectly and weren't allowing my script to delete any sessions when calling session_destroy();.

Here is my question.
What happens to the session data from sessions where a user just closes the browser and doesn't call the session_destroy();.

I remember reading somewhere that PHP automatically deletes old sessions every so often, but that didn't seem to be happening in this case. That is unless PHP is trying to delete those files as IUSR on a windows platform.

Any ideas here. Do I need to run a scheduled job to delete the old session files in the folder?

Posted: Fri Dec 12, 2003 8:58 pm
by john_iles2000
That's also my probelm. Now, my question is:

1. How can i delete or destroy session variables if the user close the browser?

2. How can i delete a session if the user visits another site through the same window or browser?


I hope php gurus can help me about this problem


Thanks.........

Posted: Fri Dec 12, 2003 9:17 pm
by microthick
This is from php.ini:

; NOTE: If you are using the subdirectory option for storing session files
; (see session.save_path above), then garbage collection does *not*
; happen automatically. You will need to do your own garbage
; collection through a shell script, cron entry, or some other method.
; For example, the following script would is the equivalent of
; setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
; cd /path/to/sessions; find -cmin +24 | xargs rm

And regarding the subdirectory option:

; Argument passed to save_handler. In the case of files, this is the path
; where data files are stored. Note: Windows users have to change this
; variable in order to use PHP's session functions.
; As of PHP 4.0.1, you can define the path as:
; session.save_path = "N;/path"
; where N is an integer. Instead of storing all the session files in
; /path, what this will do is use subdirectories N-levels deep, and
; store the session data in those directories. This is useful if you
; or your OS have problems with lots of files in one directory, and is
; a more efficient layout for servers that handle lots of sessions.
; NOTE 1: PHP will not create this directory structure automatically.
; You can use the script in the ext/session dir for that purpose.
; NOTE 2: See the section on garbage collection below if you choose to
; use subdirectories for session storage


---

Just fishing out info that might be of help later to other responders.

Posted: Fri Dec 12, 2003 9:29 pm
by infolock
just adding to this, cookies are also something to be considered.