Re: UNSETing Session Variables

From: Date: Mon, 08 Jul 2002 20:21:43 +0000
Subject: Re: UNSETing Session Variables
Groups: php.general 
Request: Send a blank email to php-general+get-106171@lists.php.net to get a copy of this message
You only have to register the session variables once. If you need to register the same variables again (such as for a different user), then you should use session_destroy() before registering the variables again. The variables should be available throughout your pages as long as session_start() is done before ANY output goes to the HTML. It's usually best to have it as the FIRST thing on your pages. Martin >>> <jepadilla@bh-corp.com> 07/08/02 04:19PM >>> /me feels kinda dumb now. Well even after adding session_start to my connect.inc, it doesn't work. I only need to do session_register() once correct? Or do I need to do that everytime I do session start? If I have to do it everytime then what is the point of sessions? Jed "Kevin Stone" <kevin@helpelf.com> 07/08/2002 02:12 PM To: <jepadilla@bh-corp.com>, <php-general@lists.php.net cc: Subject: Re: [PHP] UNSETing Session Variables I fear you're missing something fundemental here. The active session needs to be requested for each script. So session_start() needs to be called at the top of each script (or at least before any output). Example.. page 1 ---------- <? session_start(); $myvar = "foo bar"; session_register('myvar'); // or // $_SESSION['myvar'] = $myvar; ?> page 2 --------- <? session_start(); unset($_SESSION['myvar']; // or // session_unregister('myvar'); ?> ----- Original Message ----- From: jepadilla@bh-corp.com To: Kevin Stone Cc: jepadilla@bh-corp.com ; php-general@lists.php.net Sent: Monday, July 08, 2002 2:05 PM Subject: Re: [PHP] UNSETing Session Variables Sorry about that I should have been more detailed. session_start() and all of my session_register() calls happen on login.php here is a sample session_register call. session_register("currentbid"); I am under the impression that I only need one session register call. Jed "Kevin Stone" <kevin@helpelf.com> 07/08/2002 02:00 PM To: <jepadilla@bh-corp.com> cc: <php-general@lists.php.net> Subject: Re: [PHP] UNSETing Session Variables $_SESSION['currentbid'] isn't available until you do session_start(); session_start(); unset($_SESSION['currentbid']); Or is this what does connect.inc contains? -Kevin ----- Original Message ----- *snip please see previous messages for this information snip*

« previous php.general (#106171) next »