sessions stopping and starting

Busy's picture

He has: 6,151 posts

Joined: May 2001

OK, hopefully I wont confuse anyone with this problem Laughing out loud

page1 has the variable (session set)
going to page 2 displays the variable

now this is where it gets tricky, If the person goes back to page1 one, i want the session to end before the content is reloaded, but if the person goes to page3 or page4, page8 ... I want the session to continue sessioning (my new word of the day Laughing out loud )

doh gotta go, big lightning storm, will finish this later

He has: 1,016 posts

Joined: May 2002

Well, can't you put an if statement in page1 that checks to see if a session variable is set, if so it can clear them and close the session.

Busy's picture

He has: 6,151 posts

Joined: May 2001

tryed that but if the person starts on page2 then goes to page3, the page2 session is sent over, so everypage has its own session variables and I'll have no way in knowing what page they started on.
I have over 2000 pages so dont want to include a masive array.

the variable I am sessioning is drawn from the database, then passed to another page but has to be cleared if returning to the first page which will display another variable to session.

nike_guy_man's picture

They have: 840 posts

Joined: Sep 2000

If they start at page 2 or 3 or 4, do you want them to have a new session started? or only on 1?

Busy's picture

He has: 6,151 posts

Joined: May 2001

session would sart at the page they are on and continue to the next (1-2, 8-9, 2-3 ..) but going backwards would have to end it before the new one is set.

I think I might of found something that will work, trail and error I suppose, I'll let you know what I found/get

nike_guy_man's picture

They have: 840 posts

Joined: Sep 2000

<?php
session_start
();
if (
$HTTP_SESSION_VARS) {
page
session_unregister
(variable);
} else {
session_register(variable);
}
?>

is that what you are looking for???

Laughing out loud

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.