SourOddity
SourOddity

Reputation: 141

Why is my session unset/ destroy not working?

On my page I have a session being created which can be accessed and called fine usually. However, I am adding a logout button which links to logout.php which only contains the lines

session_unset();
session_destroy();

Noting out the session_destroy, I've noticed that there is no error, but nothing happens to the current session. However, session_destroy is giving the following error. Similar questions show that this is because people have not called session start, but the session has been started in my login.php

error

Upvotes: 0

Views: 64

Answers (1)

Satyajit Bhatt
Satyajit Bhatt

Reputation: 261

You got error in your logout.php page. You wrote only two lines but try to add one line at the top of the page in your PHP scope.

session_start();
session_destroy();

It will work...!!!

Upvotes: 2

Related Questions