|
-
February 5th, 2007, 08:13 PM
#1
active sessions
Hey guys, I've searched the forum and havn't seen anything simular to what i'm asking so here it is.
Is there a way to find out how many sessions are still active from a server point of view.
Example i have John and Lucy both searching my site. Each has their own PHPSESSID going. current active sessions are 2. Then Bob joins making active sessions 3. Lucy's session times out and back down to 2. I know the count would only determine number of active sessions at page load but have been going over everything i can think of and can't figure out a way to code this any help?
-
February 5th, 2007, 09:56 PM
#2
Re: active sessions
PHP cannot do this of itself. You will have to create a custom session handler and work with a database to store the active sessions. When someone destroys a session (logs out), you must then delete it from the database.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
February 5th, 2007, 10:04 PM
#3
Re: active sessions
is there a way to destroy session when user leaves site and/or close browser?
-
February 6th, 2007, 01:03 AM
#4
Re: active sessions
 Originally Posted by cypher5783
is there a way to destroy session when user leaves site and/or close browser?
That is done automatically by PHP. You can configure PHP on what circumstances sessions should be deleted. It's somewhat called garbage-collection.
About counting active visitors, you must define what an active visitor is. Personally I consider active visitor all surfers who have not closed the website window yet and the last activity occurred in the last 15 minutes.
All consequences are eternal in some way.
-
February 6th, 2007, 02:05 AM
#5
Re: active sessions
well, if you have a way of detecting when the user closes the browser window/leaves the page, you can forcfully destroy the session with session_destroy.
if you just want to know how to safely overwrite php's session functions, check session_set_save_handler.
There also some ready-to-use tools out there which hook onto php sessions functions and save the sessions data in databases.
the good think with session_set_save_handler is, that you can just go on and use the normal session functions and the $_SESSION array.
there are 10 kinds of people. those who understand binary and those who don't...
rate a post if you find it usefull, thx
check out my Firefox/Mozilla Extension: http://urlparams.blogwart.com/
-
February 7th, 2007, 04:14 AM
#6
Re: active sessions
Just to clarify, a session is usualy destroyed when the browser closes. You can set the time on the session so that it expires after a period of time. If you want the session to be active when the browser reopens I think you have to use cookies instead.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|