Jump to content

[SOLVED] logout / end session


richiec

Recommended Posts

Hey there, i have the login all set up and im trying to add a logout option however its not working lol

 

this is what i have

 

//registers session on login
session_register("myusername");
session_register("mypassword");

 

now on logout.php i would have thought it would be something like...

 

<?
session_unregister("myusername");
session_unregister("mypassword");
echo "you are now loged out."
?>

 

It echos the "you are now loged out." but it doesnt actualy log you out. Any ideas of what im doing wrong?

Link to comment
https://forums.phpfreaks.com/topic/73716-solved-logout-end-session/
Share on other sites

your probably missing session_start();

 

Personally..i would do this.. kinda overkill but works..

session_start();
$_SESSION["myusername"]  ="";
$_SESSION["mypassword"]  ="";
unset($_SESSION['myusername']);
unset($_SESSION['mypassword']);
session_destroy();

You forgot session_start();

 

And, as of PHP 4 (I think) session_(un)register() is depricated....

 

yeah i didnt on the logout.php thanks.

 

 

your probably missing session_start();

 

Personally..i would do this.. kinda overkill but works..

session_start();
$_SESSION["myusername"]  ="";
$_SESSION["mypassword"]  ="";
unset($_SESSION['myusername']);
unset($_SESSION['mypassword']);
session_destroy();

 

i tried that and it does log me out now so thanks for that. However it does log me out but it gives me this error

 

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/www/fearedwarlords.dks-gfx.com/new/login/logout.php:9) in /home/www/fearedwarlords.dks-gfx.com/new/login/logout.php on line 44

you are now loged out.

 

Line 44 is session_start();

 

any ideas?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.