简体   繁体   中英

Ending A Session, Redirect to Another Page

I am trying to redirect to another page upon breaking a session and destroying session variables.

Here is my code to logout:

<?php

_$SESSION['signin'] = null;

session_destroy();

header("Location: /index.php");

?>

I thought this was quite straight forward, however it simply stays on the logout.php page, and does not get redirected to the index page.

I assume his has something to do with destroying the session, kind of like an "exit" in php.

How can I go about redirecting then though?

you appear to heave a simple syntax error in your first line:

WAS:

_$SESSION['signin'] = null;

It should be:

$_SESSION['signin'] = null;

NOTE: You probably have error messages suppressed/hidden. When in development, you should have them enabled, you would have figured out this error very easily.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM