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
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.