Im quitting sessions!

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
lazersam
Forum Contributor
Posts: 105
Joined: Sat Nov 15, 2003 4:07 am
Location: Hertfordshire, UK

Im quitting sessions!

Post by lazersam »

I have redesigned a big project in favour of sessions to keep track of my variables. The thing is one variable (not all) is incrementing by 1 everytime I start a session.

I cant find any reason for it whatsoever! On every page I test, it increments it by 1. There is no code or counters going... nothing!

The variable is $aff_id - it also comes in via the URL but so do other variables but they do not increment.

Any ideas?

Lawrence.

ps I think it is related to me not destoying sessions as I test the script. I think it is keeping an old value.
User avatar
Derfel Cadarn
Forum Contributor
Posts: 193
Joined: Thu Jul 17, 2003 12:02 pm
Location: Berlin, Germany

Post by Derfel Cadarn »

ps I think it is related to me not destoying sessions as I test the script. I think it is keeping an old value.
And? Were U right?
If not you could give some code here perhaps? :wink:
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

You must be increasing the variable somewhere... they don't change unless you tell them to!

When you destroy a session make sure you unset the variables before destroying it... session_unset(); session_destroy();

Don't forget you all need session_start() at the top of each page which you know will need to access the session variables.
User avatar
lazersam
Forum Contributor
Posts: 105
Joined: Sat Nov 15, 2003 4:07 am
Location: Hertfordshire, UK

Post by lazersam »

Its very hard to test as now it works ok despite not working correctly yestoday. I am trying to re-create the variables and the the order I tested it but now it annoyingly works like a charm.

I think im going to destroy_session using a sub-script before starting a session every single time now.

It would be nice to destroy_session when the user leaves the domain - anyone know how to do that?

Lawrence.
Post Reply