1

I realise this has been asked before but i have gone over the previous questions to no avail.

I am getting no errors, just a blank page when I logout and kill the session. The session dies but no redirect :(

Here is the include for logout

<?php
// Initialize the session.

session_start();

// Unset all of the session variables.
$_SESSION = array();

// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
    $params["path"], $params["domain"],
    $params["secure"], $params["httponly"]
);
}

// Finally, destroy the session.
session_destroy();

if(PHP_SESSION_NONE === true){

//i added this conditional statement as a last ditch, there was no if statement to begin with just a simple redirect, neither work.     

header("Locaction: index.php");
}
?>

Here is my form code.

<form action="endSession.php" method="post" id="end_session">
<button type="submit" name="end_session" id="end_button">Logout</button>
</form>
red_starz
  • 49
  • 7
  • Please check your spelling `header("Locaction: index.php");` it is `Locaction` but should be `Location` – Nehal Feb 17 '16 at 11:02

4 Answers4

2

Spelling mistake in header. It's Location not Locaction.

It should be like : header("Location: index.php");

Please refer this : http://php.net/manual/en/function.header.php

Mr. Engineer
  • 3,522
  • 4
  • 17
  • 34
2

PHP_SESSION_NONE is only a constant.

You have to check the session status.

if (session_status() === PHP_SESSION_NONE)
Klaus
  • 727
  • 8
  • 13
2

You've misspelled Location:

//Your spelling
header("Locaction: index.php");

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

Reference


Also, PHP_SESSION_NONE is, as far as I can see, being used incorrectly. It is the return value of session_status(), so you should use it like so:

if(session_status() === PHP_SESSION_NONE){ //...

Although better practice would be:

if(session_status() !== PHP_SESSION_ACTIVE){ //...

Reference

Ben
  • 8,894
  • 7
  • 44
  • 80
1

You'll typed Location as Locaction.

Please check your error messages. You can refer to this post on how to check for error messages: How to get useful error messages in PHP?.

Alternatively, you can try using a online syntax checker: http://phpcodechecker.com, but enabling it in your server is still the best way.

Community
  • 1
  • 1
Panda
  • 6,955
  • 6
  • 40
  • 55