Re: [PHP] Sessions again....
Suhas wrote: Hello, I am trying to understand how sessions work. I have this code. My understanding is after 1 sec of script completion, (may be little after that), the session should destroy. I understand that it is huge overhead for server, not planning to do this but want to understand how it really works. This server uses cookie to store session. Setings in php.ini file are defaut (1440 and probility is 1) ini_set('session.auto_start', '0'); this ini setting can onyl be set before php starts - setting inside your script does nothing. I THINK. session_id('SSP'); I wouldn't make the call to session_id() - not like that anyway - insecure springs to mind - read more here: http://php.net/session_id IHMO you should just let php handle session id generation. session_cache_limiter("nocache"); this function call determine the kind of caching headers that will be sent. yuor pages should not be cached by the browser or any intermediary proxy. ini_set('session.cookie_lifetime', '0'); this sets you session cookie to last for as long as you keep the browser open. ini_set('session.gc_probability', '100'); ini_set('session.gc_divisor', '100'); ini_set('session.gc_maxlifetime', '1'); these 3 ini setting have to do with garbage collection (gc) of stale session data (files) - the numbers you use 100 & 100 mean that the garbage collector will be run at the end of every request - thats very bad for performance. session.gc_maxlifetime doesn't seem to be being honored .. this may be down to your version of php, your OS, a combination thereof - or it may even be that the value is too small to be meaningful. or the session.cookie_lifetime may be interfering - I just don't know but seems _like_ incorrect behaviour bare in mind that although you are calling ini_set() on all these setting that does not mean that any of the values you give are actually being set successfully - use ini_get() after your call to session_start() and echo out the results to determine what values are actually in affect. session_start(); indeed - you must call session_start() before trying to use $_SESSION if(!session_is_registered('count')) session_register('count'); echo ++$_SESSION['count']; don't mix the use session_register() and the $_SESSION superglobal - in fact just use the $_SESSION superglobal and forget session_reigster completely i.e. you can just do: if (!isset($_SESSION['count'])) { $_SESSION['count'] = 0; } $_SESSION['count']++; Any help will be appriciated! HTH (I might need correcting on some of the details - anyone care to chip in?) Thanks SP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions again....
Well script is not working as it is supposed to be. Even after 2 hrs I visit the page the count variable increases by 1 than prevois value. Any reason why is that so? If my understanding is not correct please correct me. Thanks SP On 8/4/05, James <[EMAIL PROTECTED]> wrote: > So what is your question...? > > - Original Message - > From: "Suhas" <[EMAIL PROTECTED]> > To: "php-general" > Sent: Thursday, August 04, 2005 4:13 PM > Subject: [PHP] Sessions again > > > Hello, > I am trying to understand how sessions work. I have this code. My > understanding is after 1 sec of script completion, (may be little > after that), the session should destroy. > > I understand that it is huge overhead for server, not planning to do > this but want to understand how it really works. > > This server uses cookie to store session. Setings in php.ini file are > defaut (1440 and probility is 1) > > > ini_set('session.auto_start', '0'); > session_id('SSP'); > session_cache_limiter("nocache"); > ini_set('session.cookie_lifetime', '0'); > ini_set('session.gc_probability', '100'); > ini_set('session.gc_divisor', '100'); > ini_set('session.gc_maxlifetime', '1'); > session_start(); > > if(!session_is_registered('count')) > session_register('count'); > > echo ++$_SESSION['count']; > > Any help will be appriciated! > > Thanks > SP > > -- > 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 > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions again....
session.cookie_lifetime integer session.cookie_lifetime specifies the lifetime of the cookie in seconds which is sent to the browser. The value 0 means "until the browser is closed." Defaults to 0. See also session_get_cookie_params() and session_set_cookie_params(). - Original Message - From: "Suhas" <[EMAIL PROTECTED]> To: "James" <[EMAIL PROTECTED]>; "php-general" Sent: Thursday, August 04, 2005 4:35 PM Subject: Re: [PHP] Sessions again Well script is not working as it is supposed to be. Even after 2 hrs I visit the page the count variable increases by 1 than prevois value. Any reason why is that so? If my understanding is not correct please correct me. Thanks SP On 8/4/05, James <[EMAIL PROTECTED]> wrote: So what is your question...? - Original Message - From: "Suhas" <[EMAIL PROTECTED]> To: "php-general" Sent: Thursday, August 04, 2005 4:13 PM Subject: [PHP] Sessions again Hello, I am trying to understand how sessions work. I have this code. My understanding is after 1 sec of script completion, (may be little after that), the session should destroy. I understand that it is huge overhead for server, not planning to do this but want to understand how it really works. This server uses cookie to store session. Setings in php.ini file are defaut (1440 and probility is 1) ini_set('session.auto_start', '0'); session_id('SSP'); session_cache_limiter("nocache"); ini_set('session.cookie_lifetime', '0'); ini_set('session.gc_probability', '100'); ini_set('session.gc_divisor', '100'); ini_set('session.gc_maxlifetime', '1'); session_start(); if(!session_is_registered('count')) session_register('count'); echo ++$_SESSION['count']; Any help will be appriciated! Thanks SP -- 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sessions again....
Hello, I am trying to understand how sessions work. I have this code. My understanding is after 1 sec of script completion, (may be little after that), the session should destroy. I understand that it is huge overhead for server, not planning to do this but want to understand how it really works. This server uses cookie to store session. Setings in php.ini file are defaut (1440 and probility is 1) ini_set('session.auto_start', '0'); session_id('SSP'); session_cache_limiter("nocache"); ini_set('session.cookie_lifetime', '0'); ini_set('session.gc_probability', '100'); ini_set('session.gc_divisor', '100'); ini_set('session.gc_maxlifetime', '1'); session_start(); if(!session_is_registered('count')) session_register('count'); echo ++$_SESSION['count']; Any help will be appriciated! Thanks SP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions again....
So what is your question...? - Original Message - From: "Suhas" <[EMAIL PROTECTED]> To: "php-general" Sent: Thursday, August 04, 2005 4:13 PM Subject: [PHP] Sessions again Hello, I am trying to understand how sessions work. I have this code. My understanding is after 1 sec of script completion, (may be little after that), the session should destroy. I understand that it is huge overhead for server, not planning to do this but want to understand how it really works. This server uses cookie to store session. Setings in php.ini file are defaut (1440 and probility is 1) ini_set('session.auto_start', '0'); session_id('SSP'); session_cache_limiter("nocache"); ini_set('session.cookie_lifetime', '0'); ini_set('session.gc_probability', '100'); ini_set('session.gc_divisor', '100'); ini_set('session.gc_maxlifetime', '1'); session_start(); if(!session_is_registered('count')) session_register('count'); echo ++$_SESSION['count']; Any help will be appriciated! Thanks SP -- 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
[PHP] Sessions again....
Hello, I am trying to understand how sessions work. I have this code. My understanding is after 1 sec of script completion, (may be little after that), the session should destroy. I understand that it is huge overhead for server, not planning to do this but want to understand how it really works. This server uses cookie to store session. Setings in php.ini file are defaut (1440 and probility is 1) ini_set('session.auto_start', '0'); session_id('SSP'); session_cache_limiter("nocache"); ini_set('session.cookie_lifetime', '0'); ini_set('session.gc_probability', '100'); ini_set('session.gc_divisor', '100'); ini_set('session.gc_maxlifetime', '1'); session_start(); if(!session_is_registered('count')) session_register('count'); echo ++$_SESSION['count']; Any help will be appriciated! Thanks SP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] sessions.. again...
Few of us have time to play with your script, but if you refer to the fact that the form you submitted and once new page came up - you clicked back seeing nothing, that is something that happens most of the time. As Sascha once explained that to me - that is the way Sessions work. well, if that is not what you're referring to, then please copy that code in your email and we'll think about it. Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) [EMAIL PROTECTED] www.phpbeginner.com -Original Message- From: Miguel Loureiro [mailto:[EMAIL PROTECTED]] Sent: Friday, March 23, 2001 3:43 AM To: php-gen Subject: [PHP] sessions.. again... Hello all, I'm mad with mesorry but see if can understand why I'm mad. Copy the 3 attached files, and run it. In one.php just click to the link (it works.), now in two.php you can see: " and now: aaa", cool hum... Clicking in OFF link you can see the result of phpinfo, but section of Apache Evironment, in HTTP_COOKIE you (at least I have) the PHPSESSID with value, in spite of in off.php code I make a session_destroy Now if you use history back button, go to two.php, and OK the session variable dont appear, Back again, Forward and voila' here is a. I have try to follow some Jeff Armstrong tips, but I have no success.Thank you very much Jeff (really...I'm no jocking...). Any ideas ?? T.Y all Best Regards Miguel Loureiro <[EMAIL PROTECTED]>
Re: [PHP] sessions.. again...
attachments ar stripped for security purposes by the mailing list server. please post the code in your msg. -- Chris Lee [EMAIL PROTECTED] ""Miguel Loureiro"" <[EMAIL PROTECTED]> wrote in message 00ad01c0b2ff$f12a9c00$[EMAIL PROTECTED]">news:00ad01c0b2ff$f12a9c00$[EMAIL PROTECTED]... Hello all, I'm mad with mesorry but see if can understand why I'm mad. Copy the 3 attached files, and run it. In one.php just click to the link (it works.), now in two.php you can see: " and now: aaa", cool hum... Clicking in OFF link you can see the result of phpinfo, but section of Apache Evironment, in HTTP_COOKIE you (at least I have) the PHPSESSID with value, in spite of in off.php code I make a session_destroy Now if you use history back button, go to two.php, and OK the session variable dont appear, Back again, Forward and voila' here is a. I have try to follow some Jeff Armstrong tips, but I have no success.Thank you very much Jeff (really...I'm no jocking...). Any ideas ?? T.Y all Best Regards Miguel Loureiro <[EMAIL PROTECTED]> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] sessions.. again...
Hello all, I'm mad with mesorry but see if can understand why I'm mad. Copy the 3 attached files, and run it. In one.php just click to the link (it works.), now in two.php you can see: " and now: aaa", cool hum... Clicking in OFF link you can see the result of phpinfo, but section of Apache Evironment, in HTTP_COOKIE you (at least I have) the PHPSESSID with value, in spite of in off.php code I make a session_destroy Now if you use history back button, go to two.php, and OK the session variable dont appear, Back again, Forward and voila' here is a. I have try to follow some Jeff Armstrong tips, but I have no success.Thank you very much Jeff (really...I'm no jocking...). Any ideas ?? T.Y all Best RegardsMiguel Loureiro <[EMAIL PROTECTED]> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Sessions again :(
try it. (yes you need to register it as a global variable) Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) [EMAIL PROTECTED] www.phpbeginner.com -Original Message- From: John Vanderbeck [mailto:[EMAIL PROTECTED]] Sent: Saturday, February 17, 2001 11:41 PM To: [EMAIL PROTECTED] Subject: [PHP] Sessions again :( Sorry about all these questions. Just a quickie. Does a session registered variable take on global scope, or do I still need to do a "global $my_session_var" to make my function see it? - John Vanderbeck - Admin, GameDesign -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Sessions again :(
Sorry about all these questions. Just a quickie. Does a session registered variable take on global scope, or do I still need to do a "global $my_session_var" to make my function see it? - John Vanderbeck - Admin, GameDesign -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]