Link to home
Start Free TrialLog in
Avatar of Amien90
Amien90

asked on

why is my session not cleared?

i have a session and this will not clear at all. i'v tried them all, Clear, Remove etc.
Nothing works .. if the browser is closed and then opened again, it will be cleared ofcourse

strange thing is that my code didn't change and worked perfect before. Can there be other settings involved? like IE?
Avatar of BuggyCoder
BuggyCoder
Flag of India image

do this
Session["ID"]=null
where you want to clear your session say at the time of use log out, rather than using clear or remove.
Avatar of Amien90
Amien90

ASKER

session is still there
Avatar of Stephan
Is there anything else happening on your webpage? Maybe a Response.Redirect?
You could also try Session.Abandon();

Let me know what else is happening when you remove a Session if the above didn't work.
Avatar of Amien90

ASKER

Abandom also doesn't work ..

my code didnt change .. i also tried old version of my code where i'm sure that the session was cleared. In my old version the session is also not cleared
Can you provide some more information, like what is your application doing, when do you check your session etc..

There are many scenario's when a Session is not removed, can you put the code inside an separate application and is the problem still there? Maybe you could post that code so we can reproduce the issue
Avatar of Amien90

ASKER

why do you say Reponse.Redirect btw?

i do first a Session.Clear,Remove etc.
And then a Reponse.Redirect right after that
ASKER CERTIFIED SOLUTION
Avatar of Stephan
Stephan
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try Session.Clear() or Session.RemoveAll();

Also read below:-

When you abandon a session, the session ID cookie is not removed from the browser of the user. Therefore, as soon as the session has been abandoned, any new requests to the same application will use the same session ID but will have a new session state instance.

Read more about sessions here:-
http://abhijitjana.net/2011/06/04/asp-net-internals-clearing-asp-net-session-variables-a-in-depth-look/
http://support.microsoft.com/?kbid=899918
Avatar of Amien90

ASKER

btw .. whats the workaround with session clear and redirect? nestle a redirect in a IF session = nothing, will not be usable i think