[PHP] Lifetime
I'm curious to know what the lifetime of a constant is. I know that sounds like a stupid question, but the context is this: I have a file I am writing to up to the very last possible micro-second. As such, I know that as PHP is destroying itself after having executed the last statement in the program, things begin to disappear. The Class objects destruct in no discernable order (they have destructors). Any open file handles close. Etc. My question is: During all this destruction, at what point must I no longer expect to have a constant available? That is, when the classes are executing their __destruct() functions, et al, I want to manage something with those destructors. So when does the constant actually-factually disappear? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Lifetime
Constants are available as long as the PHP process is executing. Destructors are called before a class instance is being wiped out from memory. But it does not remove a class or undefine a class. It works with instance. So a class constant never gets undefined. It stays with class definition.
[PHP] Lifetime with cookie-less sessions
Hello, Is it possible to determine a lifetime for the session in the case of a cookie-less sessions ? Thanks for your help. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Lifetime with cookie-less sessions
I just took a thorough look at the Session Handling section in the manual. I couldn't even find any mention of non-cookie session lifetimes. I get the impression they either die on broswer close or have a fixed lifetime that cannot be changed. Hopefully someone can prove me wrong, if only for amusement value. ;) Edward Dudlik Becoming Digital www.becomingdigital.com - Original Message - From: Cranky [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, 24 September, 2003 05:42 Subject: [PHP] Lifetime with cookie-less sessions Hello, Is it possible to determine a lifetime for the session in the case of a cookie-less sessions ? Thanks for your help. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Lifetime with cookie-less sessions
Becoming Digital wrote: I just took a thorough look at the Session Handling section in the manual. I couldn't even find any mention of non-cookie session lifetimes. I get the impression they either die on broswer close or have a fixed lifetime that cannot be changed. Hopefully someone can prove me wrong, if only for amusement value. ;) It works something like this: Used goes to www.foobar.com, session ID is 1 Used clicks on link to foo.php, which has been automagically changed to foo.php?PHPSESSID=1 PHP sees the PHPSESSID GET variable, and uses session ID 1. User goes to some other site, then comes back to foobar.com by typing it into their address bar PHP has no way to know the session ID since the user didn't add ?PHPSESSID=1 to the URL, so it uses session ID 2 with new session data -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Lifetime with cookie-less sessions
session.gc_maxlifetime integer session.gc_maxlifetime specifies the number of seconds after which data will be seen as 'garbage' and cleaned up. Note: If you are using the default file-based session handler, your filesystem must keep track of access times (atime). Windows FAT does not so you will have to come up with another way to handle garbage collecting your session if you are stuck with a FAT filesystem or any other fs where atime tracking is not available. Cranky wrote: Hello, Is it possible to determine a lifetime for the session in the case of a cookie-less sessions ? Thanks for your help. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Lifetime with cookie-less sessions
On Wed, 24 Sep 2003 11:42:12 +0200 Cranky [EMAIL PROTECTED] wrote: Hello, Is it possible to determine a lifetime for the session in the case of a cookie-less sessions ? Thanks for your help. In my sessions I set an expire time, which is the current time (unix timestamp) plus the number of seconds I want a session to last. Each new page examines the current timestamp against the expire time. If the current time is less than the expire time, then the expire time is advanced again. Otherwise, the session is wiped out and the user sent to an error page. $defExpireTime = 3600; if ($_SESSION['expire'] = (time() + $this-defExpireTime) { $_SESSION['expire'] = time() + $this-defExpireTime; # go ahead with session } else { $_SESSION = array(); # send the user to an error page } -- Raquel What lies behind us and what lies between us are tiny matters compared to what lies within us. --Oliver Wendell Holmes -- Raquel What lies behind us and what lies between us are tiny matters compared to what lies within us. --Oliver Wendell Holmes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Lifetime with cookie-less sessions
I just come to do some test this afternoon and here are the results. page_1.php ?php session_start(); $bar = 'hello'; $now = date('H:i:s'); $_SESSION['foo'] = $bar; $_SESSION['begin'] = $now; header('Location: page_2.php?'.SID); exit; ? page_2.php ?php session_start(); print_r($_SESSION); echo 'brNow : '.date('H:i:s'); ? a href=page_2.php??php echo SID; ?Reload/a And here are the results : Config session.use_cookie = 0; session.gc_maxlifetime = 30; // 30 seconds session.gc_probability = 100; // 100% = the gc is always called On page 2, I have : Array ( [begin] = 16:34:22, [foo] = hello ) Now : xx:xx:xx I have this at the beginning and when I reload the page with the link, these information are the same (only = Now : xx:xx:xx changes as expected). But after a little bit more that 30 seconds (never exactly 30 seconds) the gc is called and I have : Array () Now : xx:xx:xx And I do the same test with this config : Config session.use_cookie = 0; session.gc_maxlifetime = 1440; // 24 minutes session.gc_probability = 1; // 1% = the gc is called 1 time on 100 And here at the beginning all is correct, I refresh the page 2 every 15 minutes and here, the session is destroyed randomly after 1h20, 1h50... So it seems that the lifetime on a cookie_less session is determined by the gc.max_lifetime. Thanks for your help Raquel Rice wrote: In my sessions I set an expire time, which is the current time (unix timestamp) plus the number of seconds I want a session to last. Each new page examines the current timestamp against the expire time. If the current time is less than the expire time, then the expire time is advanced again. Otherwise, the session is wiped out and the user sent to an error page. $defExpireTime = 3600; if ($_SESSION['expire'] = (time() + $this-defExpireTime) { $_SESSION['expire'] = time() + $this-defExpireTime; # go ahead with session } else { $_SESSION = array(); # send the user to an error page } -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php