Page 1 of 1

end session and reload page from within logout function?

Posted: Sat Dec 06, 2008 6:28 am
by sjk1000
Hi all
I've a logout button that runs a function to destroy the session and then return to the same page. The location of the logout function within the script means that on the button click the user doesn't return to login prompt as I'd like. A page reload at this point instantly deals with it. I'd rather not rework the flow of the script because this is the last thing I'm doing on the page. How do I force the browser to reload the page from within the logout function?
Thanks, Steve

Re: end session and reload page from within logout function?

Posted: Sat Dec 06, 2008 6:39 am
by dark_religion
did you try header("Location: http://domain/login.php") ?

Re: end session and reload page from within logout function?

Posted: Sat Dec 06, 2008 7:09 am
by sjk1000
OK I've solved the problem but I don't understand how. I did it by calling the seller_logout function from within itself which has a similar effect to refreshing the page - [insert mixed emotions smiley here]. Can someone explain why this works? Thanks

Code: Select all

<?php
function seller_logout()
{
unset($_SESSION['valid_user']);
session_destroy();
seller_logout ();
}
?>

Re: end session and reload page from within logout function?

Posted: Sat Dec 06, 2008 7:15 am
by sjk1000
ps thanks for your reply dark_religion. I mucked around for a while trying to figure out where I was supposed to put it in the function with no success. If I hadn't found the weird workaround above, where would it go?
Thanks, Steve