Re: session_destroy AND reload a page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Nov 26, 2007 12:45 AM, Chris <dmagick@xxxxxxxxx> 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

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux