Page 1 of 1

getting the number of sessions

Posted: Sat Jul 26, 2003 5:01 pm
by psychotomus
is there away to get the number of sessions currently in use like $_SESSION['test'], to get how many users on the site have a #_SESSION['test'] variable in use?

Posted: Sun Jul 27, 2003 5:54 pm
by psychotomus
i guess this isnt possible?

Posted: Sun Jul 27, 2003 11:14 pm
by Sevengraff
I think usually when you create a session you log it in a file or database some where with a timestamp. I dont use sessions though.

Posted: Sun Jul 27, 2003 11:18 pm
by nielsene
Are you using the default "file" based session or a custon DB handler?
In either case it should be possible to find the information you want. In the former case you can count the number of files in the tmp folder. If you want to know what variables are set you'll have to parse the files there.

If you're using a custom DB handler it should be trivial to gather either piece of information, but the exact method will depend on your handler.

Posted: Mon Jul 28, 2003 4:57 pm
by psychotomus
im using session_start(); then later i do

$_SESSION['whatever'] = "test";

where are these files stored at?

Posted: Mon Jul 28, 2003 4:59 pm
by kcomer
Wouldn;t counting the files /tmp give you ALL the sessions if your using shared hosting, not just your sites?

Keith

Posted: Mon Jul 28, 2003 11:06 pm
by psychotomus
im trying to get the number of users logged into my site, i figure the easyest way to do it is by getting the number of $_SESSIONS' i have open since if they dont have a specific session set they cant log in or browse other pages on the site.