[PHP] Logout / Destroy Session

Status
Not open for further replies.

brsy

nah mang
May 12, 2011
1,530
272
PHP:
<?php
 
session_start();
session_destroy();
 
if(session_destroy()) {
    header("Location: http://pabbo.net/index.php");
}
 
?>

Would the if statement be valid?
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,637
2,389
You don't really need the if statement. Just do
PHP:
<?php
session_start();
session_destroy();
header( "Location: http://pabbo.net/index.php");
?>
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,637
2,389
Actually he's right, you may have other sessions set and don't want to destroy them. Using session_destroy will destroy all sessions you have on that web-server., where as using unset() you can just destroy specific sessions.
 
Status
Not open for further replies.

Users who are viewing this thread

Top