Sessions not getting deleted

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Chambrln
Forum Commoner
Posts: 43
Joined: Tue Dec 02, 2003 10:45 am
Location: Oregon

Sessions not getting deleted

Post 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?
john_iles2000
Forum Newbie
Posts: 1
Joined: Fri Dec 12, 2003 8:58 pm

Post 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.........
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post 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.
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

just adding to this, cookies are also something to be considered.
Post Reply