Re: session_destroy AND reload a page
| From: | Philip Thompson | Date: | Mon, 26 Nov 2007 16:34:05 +0000 |
| Subject: | Re: session_destroy AND reload a page | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-265030@lists.php.net to get a copy of this message | ||
On Nov 26, 2007 12:45 AM, Chris <dmagick@gmail.com> wrote:
> Ronald Wiplinger wrote:
> > If my user wants to logout, I want that the session will be destroyed
> > and that he must start with the first page again (index.php) and a new
> > session.
> >
> > Whatever I try he always gets the old sessions or he does not come to
> > the first page.
>
> What code do you have?
>
A very crude way to do this....
$_SESSION = array();
However, this will destroy EVERY variable within the session. This is bad if
you have multiple sites on one server. To organize your session variables,
you may try storing them as......
$_SESSION['aSiteName']['is_logged_in'],
$_SESSION['aSiteName']['var1'],
$_SESSION['aSiteName']['var2'],
etc
To destroy all variables within this site ('aSiteName' being this example),
do...
$_SESSION['aSiteName'] = array();
OR
unset ($_SESSION['aSiteName']);
HTH
~Philip