Jump to content

[SOLVED] Need help Destroying Sessions!


I Am Chris

Recommended Posts

ok so i have this code

<?php
session_start();
if ($_SESSION['logged'] == 1) // User Logged In
echo ("<a href=\"logout.php\">Logout</a>");
else  echo  "<a href=\"register.php\">Register</a>" . "<br />" . "<a href=\"login.php\">Login</a>";
?>

 

It's all working well. However, the logout page isn't working

this is my code for logout.php

<?php
session_unset();
session_unset();
session_destroy();
$_SESSION = array();
header("Location: index.php"); // Goes back to login.
?>

 

for some reason, it isn't deleting my session

and i stay logged in

 

is there any obveous reason why? it makes no sense to me.

please help

Link to comment
https://forums.phpfreaks.com/topic/117910-solved-need-help-destroying-sessions/
Share on other sites

hmm, works great. ty. i only spent like all day on this.

Why exactly do I have to start the session first? obveously it works, but whats the logic behind it?

is there any good knowledge base on sessions? I don't think i understand them as well as i'd like too.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.