session_destroy requires two pages?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

session_destroy requires two pages?

Post by JAB Creations »

I originally had the problem of Warning: Trying to destroy uninitialized session so I changed my code to the following...

header.php

Code: Select all

session_name("member");
session_start();
if (isset($_GET['signout'])) {session_destroy();}
...now when I load another page the user is still signed in until the second page after signing out.

I'm just trying to make this dead simple: page 1 + signed in == page 2 appears signed in. Page 2 + sign out == page 3 == appears signed out.

I've been messing with sessions for so long though only this morning decided to add a sign out link. :mrgreen:
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Re: session_destroy requires two pages?

Post by Maugrim_The_Reaper »

Have forced $_SESSION to an empty array and deleted the client side cookie?
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: session_destroy requires two pages?

Post by JAB Creations »

We lost our internet connection here because a family member hasn't paid the bill and Comcast is shutting it off at the exact moment it's due (won't have internet until tomorrow so...) I tried that according to a book to do that and I'm copying the php.net page for the destroy session function.

I also tried unsetting the $_SESSION['member'] variable and then destroying the session and that also did not work. I know that is the only variable that I have set. Not sure if I'll have net access for the rest of the day so if I don't reply you guys know why. :|
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: session_destroy requires two pages?

Post by JAB Creations »

I got it working though not dynamically...I'll have to give it another crack sometime. Oh and my internet is back...family. :roll: =
Post Reply