RE: Please help: session variable

From: Date: Wed, 24 Jun 2020 01:13:24 +0000
Subject: RE: Please help: session variable
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-327197@lists.php.net to get a copy of this message
Hi, Since it was migrated from old PHP version (5.3 or earlier), I replaced deprecated session_register(); with unconditionally initialization of session variables like following: session_start(); //session_register('logined'); $_SESSION['logined'] = ""; Then posting the form will execute these codes and cleared the session variables... Then modified the code to prevent overwriting the session variable if not null: session_start(); if(!(isset($_SESSION['logined']))) { $_SESSION['logined'] = ""; } Not sure if it's the best way to do that though it works now. Sorry for the trouble caused to you all. Thanks and rgds -----Original Message----- From: mbox@s22.us <mbox@s22.us> Sent: Tuesday, June 23, 2020 10:12 PM To: PHP General <php-general@lists.php.net> Subject: Re: Please help: session variable > On Jun 22, 2020, at 11:25 PM, ST Wong (ITSC) <ST@itsc.cuhk.edu.hk> wrote: > > After some debugging, found that the session variables are initialized unconditionally and thus > got cleared upon any post operation. Would you explain this more fully? I’m having similar problems with a script losing session variables. > It’s fixed and works now. How did you fix it? Thanks, Frank

« previous php.general (#327197) next »