$_SESSION unset not work??

greg's picture

He has: 1,581 posts

Joined: Nov 2005

I have two session say A & B

both sessions only have numerical data entered in them
both sessions get the data removed (unset) from them in the exact same way by the same file

session A gets its data from a db query (table ID)
session B gets its data from a user text input (form)

but only session A will unset?
is there any way it's something to do with the data being from a form?

an example of session B
Array ( [12] => 1 )

now if I use the unset it does this:
Array ( [12] => 1 [] => )

obviously not removing, almost like its ADDING to it without data?

again, both sessions get the data removed in EXACTLY the same way obviously with different parameters, but they have been checked 200 times

I've even tried removing the unset code for session A and is the same result
I have checked many times the code, so I can only presume there is something about sessions I dont yet know

any ideas?
Confused

They have: 173 posts

Joined: Feb 2005

I would suggest stripping it down to the core of what you want to do - set the sessions, then unset them... and see the result. If it's different from being within all your other code then you have something else happening that is messing it up. If it's the same result, then please pastebin the simple "test case" file. (http://www.pastebin.com)

SonicMailer Pro - Professional mailing list manager & award-winning email marketing software
Download a FREE 30-day trial today!
Use coupon savemoreon4 and save 10%!

greg's picture

He has: 1,581 posts

Joined: Nov 2005

thanks for replying.

I spent ages looking for the problem. nothing was reporting an error. i used php files checkers like what you suggested all said the code was fine
I went through the code meticulously and found nothing
the problem is I have several sessions doing various things in several pages within whiles and loops in php files with 70-80 lines of code in them and the problem could have been at any point of it all

I found it in the end though

I missed an "=" in a form, so the data being sent to a page that added or removed to or from the session in question wasnt getting any data to remove
a simple equals sign missing Laughing out loud

Cheers

They have: 10 posts

Joined: Oct 2007

is it possible for me to see the whole code please then I can tell you =

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.