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:[EMAIL PROTECTED]]
> Sent: Wednesday, October 16, 2002 4:04 AM
> To: [EMAIL PROTECTED]
> 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" <[EMAIL PROTECTED]> wrote in message
> 000501c274a4$ed28ae40$7c02a8c0@coconut">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




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to