Page 1 of 1
session active?
Posted: Mon Mar 15, 2004 6:19 am
by Vantuykom
How can I find out if a certain SESSID is active?
Posted: Mon Mar 15, 2004 6:33 am
by twigletmac
Active as in user is still requesting pages?
Mac
Posted: Mon Mar 15, 2004 6:43 am
by Vantuykom
yes, I want to know if the user is still requesting pages and did not close the browser without logging out...
I've found out that the sessions are staying on the server for a while, even without variables, so when I check if the session exists, I allways get 'yes'. thus I want to know if a session is active, not if it exists...
Posted: Mon Mar 15, 2004 7:12 am
by anjanesh
I don't understand either how this session in php works. It starts off well but when destroying,unregistering,unsetting etc the $PHPSESSID still remains.
I still am not sure if its a bug or our mistake. But again how are others making it work ?
You may find some useful info here :
http://www.experts-exchange.com/Web/Web ... 35728.html
Posted: Mon Mar 15, 2004 8:54 am
by anjanesh
Just found out that setcookie(session_name(),"",0,"/"); resets $PHPSESSID
Posted: Mon Mar 15, 2004 9:45 am
by Vantuykom
that's interesting, but it isn't anything I can use, I really have to know if a session is active or not...
Posted: Mon Mar 15, 2004 8:55 pm
by anjanesh
Code: Select all
<?php
if (isset($PHPSESSID))
print("Session active");
else
print("Not Active !")
?>
I think because when session_start() does not takes place there is not variable called $PHPSESSID
Posted: Tue Mar 16, 2004 4:48 am
by Vantuykom
but when somebody has another session open then it does not work
Posted: Tue Mar 16, 2004 10:41 am
by TheBentinel.com
Vantuykom wrote:but when somebody has another session open then it does not work
Do the sessions eventually time out? 20 minutes or something? If not, is that a setting?
"Active" is sort of a misnomer in a web environment. I can connect to your site, then shut off my computer. No "I'm disconnecting" messages got passed back to you. So from the server's perspective, am I active or not? How would it know?
There is a setting called keep-alive, I think it's a header. But I don't know what it means exactly. If it involves the server pinging the client to make sure it's still there, or the client pinging the server to let it know it's still there, then you'd have to balance that resource cost against the resource cost of keeping sessions around you don't need until they time out.
Another question might be, do you NEED to use sessions? If it's a problem to keep them open, you could just handle your state-saving chores in another way. Hidden fields, query strings, that sort of thing.