RE: [PHP] $_SESSION
| From: | John W. Holmes | Date: | Thu, 17 Oct 2002 00:36:54 +0000 |
| Subject: | RE: [PHP] $_SESSION | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-120259@lists.php.net to get a copy of this message | ||
You can store the variables you expect to erase in a sub-array.
$_SESSION['temp']['xx1'] = ...
$_SESSION['temp']['xx2'] = ...
$_SESSION['var'] = ...
Then, to get rid of the "temp" vars, you can use:
unset($_SESSION['temp']);
---John Holmes...
> -----Original Message-----
> From: Paonarong Buachaiyo [mailto:pao@chiangmaicar.com]
> Sent: Wednesday, October 16, 2002 4:04 AM
> To: php-general@lists.php.net
> Subject: Re: [PHP] $_SESSION
>
> Please, I' also have some question about $_SESSION.
>
> Simple, how can we earse all $SESSION variable except one or two
> variables.
>
> Beacuse i want to show some error message in my login form when login
> failed. i want to destroy all other $_SESSION variable (about 10)
except
> $_SESSION['errmsg'] and $_SESSION['errcount'].
>
> Any way to do it except
>
> unset($_SESSION['xx1']);
> unset($_SESSION['xx2']);
> unset($_SESSION['xx3']);
> .
> unset($_SESSION['xx10']);
>
> Please,
> Pao
>
> "John W. Holmes" <holmes072000@charter.net> wrote in message
> news:000501c274a4$ed28ae40$7c02a8c0@coconut...
> > > Hi All,
> > > still trying to update old code. Am I using $_SESSION properly?
> > >
> > > <snip>
> > > if (mysql_num_rows($res) ==1){
> > > /* If correct start session*/
> > > session_start();
> > > $_SESSION['SESSION_UNAME'];
> > > $SESSION_UNAME = $user;
> > >
> > > header("Location: welcome.php");
> > > mysql_free_result ($res);
> > > </snip>
> >
> > Nope. Just use $_SESSION['SESSION_UNAME'] = $user;
> >
> > You can treat $_SESSION just as you would any other array.
> >
> > $_SESSION['something'] = "whatever";
> >
> > etc... Then, on any page with session_start(), you have the whole
> > session array available to you, no matter what page the variable was
> > initially created on.
> >
> > FYI: use unset($_SESSION['SESSION_UNAME']); to erase a session
variable.
> >
> > ---John Holmes...
> >
> >
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php