View Full Version : Sessions
Slapping Penguins
01-21-2007, 02:29 PM
By default, were are the sessions stored on the server so I can make a script that counts them and tells how many are active.
hondaworkshop
01-21-2007, 08:44 PM
Open your php.ini file, search for 'session.save_path' ...should be where it is, I think
Slapping Penguins
01-22-2007, 06:44 AM
It says /tmp but I dont know which tmp folder they are talking about or where it is. Is the full path home/tmp? or the [location of the php.ini]/tmp?
Also is the path relative to the site or the user's computer
areidmtm
01-22-2007, 08:59 AM
Also is the path relative to the site or the user's computer
Sessions are stored on the server and cookies are stored on the users computer.
The sessions are stored in the top level "tmp" directory. Our accounts are stored at "/home/{USERNAME}/" so two directories above our accounts. With SSH access you can only see the file names (sess_0aef8538c0ccc967d4642f35acc7f35d). You cannot not download them, view them or edit them.
Also what you're trying to do, I don't think will work. Sessions are NOT deleted after the user closes the browser. The session is still on the server. There are still several months of session files still in my tmp directory. Further more, I'm not sure if it's limited to just your account or all accounts on the server.
You might be able to make a PHP script that will open the directory and count the files that are newer then a certain date, but still that might not be entirely accurate because they might not all be from your account.
It would be easier to create a PHP and MySQL script. Whenever someone comes to the page and a session is started, an entry is entered in to a MySQL database with a timestamp. Then create a PHP script that you run on a cron job to delete the entries after a certain time/date, or you can just do it manually.
Pethens
01-22-2007, 01:38 PM
The /tmp directory stores sessions for every account on your server. To count your own sessions, you would have to stat each file and compare the uid with your own uid. This could be an expensive operation. It would make more sense to change the session path setting in php.ini to "home/user/tmp/session", where user is your own user name, so that you have a directory consisting of only your own sessions.
Another approach, probably better, is to write a custom session handler which counts sessions. I believe PHP.net has some information about this in the documentation on sessions.
Stephen
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.