Session State and cookies

C

Chris Zopers

Hello,

I've read somewhere that sessionstate does not work when a browser has
disabled cookies, so I wanted to test this and did the following:

I added two aspx pages (c#), in the first I set a session variable like
this: Session["Test"] = "Hello";

On the first page there is a button that navigates to the second page,
like this: Server.Transfer('Default2.aspx');

In the second page in the load event, I do this:
Response.Write(Session["Test"];);

After this, I disabled all cookies in my browser (internet explorer 6)
bij using the privacy tab in IE Options. But after disabling the
cookies, my project still works fine! How's this possible or am I
understanding something wrong here?

Greetings,
Chris
 
A

Anthony Jones

Chris Zopers said:
Hello,

I've read somewhere that sessionstate does not work when a browser has
disabled cookies, so I wanted to test this and did the following:

I added two aspx pages (c#), in the first I set a session variable like
this: Session["Test"] = "Hello";

On the first page there is a button that navigates to the second page,
like this: Server.Transfer('Default2.aspx');

In the second page in the load event, I do this:
Response.Write(Session["Test"];);

After this, I disabled all cookies in my browser (internet explorer 6)
bij using the privacy tab in IE Options. But after disabling the
cookies, my project still works fine! How's this possible or am I
understanding something wrong here?



Most likely the site you are visiting is being seen as a member of the
trusted or intranet zone (probably because you are not using a FQDN). IE
will allow Session cookies for such sites regardless of your privacy
settings.
 
A

Aidy

On the first page there is a button that navigates to the second page,
like this: Server.Transfer('Default2.aspx');

The Session object will work, it just won't "remember" between page calls.
When you Server.Transfer you are still within the same page call so the
values you set are still in the Session. Do a Response.Redirect instead for
a better test.
 
C

Chris Zopers

Okay, that should be the reason, because I tested this in my visual
studio project.....thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top