Session Help

When a user is logged-out and they view the Privay Policy, I want them to not see the profile header, but if they’re logged in, I want them to see it. If the browser destroys the session, the header is gone, but if the session is manually destroyed, the header is still there. Here are the scripts “logout.php” and the script in my privacy policy.


<?php
require("includes/redirect.php");
unset($_SESSION['id']);
session_destroy();
header('Location: '. $root . $logOut);
exit;
?>


<?php
session_start();
if(!isset($_SESSION['id'])){
	
}
else{
	require("includes/userInfo.php");
	require("includes/profileHeader.php");
}
?>

Interesting.

Now, if you can put a question together, maybe throw in a please and/or thank-you - maybe of the kind folk here could help. :stuck_out_tongue:

Failing that, head on over to the Marketplace where you can save the please and thank-you, be as vague as you like and pay for the privilege.

A perfect client. :lol:

Sorry. :blush: Can someone help me debug this code please? You can see the problem in my original post. Thanks! :slight_smile:

Did you start the session in includes/redirect.php? Can’t really do a good session_destroy() when you haven’t started the session for the page with session_start()

I haven’t put “session_start()” in “redirect.php”. Should I? :confused:

Either in the file or at the top of the script. Give it a try…


<?php

session_start();
require("includes/redirect.php");

unset($_SESSION['id']);

session_destroy();

header('Location: '. $root . $logOut);

exit;

?>

Ah! That did it! Thanks for the help. I forgot the “session_start()” function so it could get (and kill) the session variable.
:eye: