Session cleared after setting cookie?

P

Paul

I'm having a problem with the session being reset after setting a
cookie. This is not supposed to happen. If I comment out the Add
line below the site works normally, the session persists. Help.

vs2003/.net 1.1

HttpCookie httpCookie = new HttpCookie("myCookieName");
httpCookie.Value = (string)Session["myString"];

// BUG: adding the cookie kills the session.
base.Response.Cookies.Add(httpCookie);
 
M

MSDN

running your test code does not kill the session on my end.

How are you testing if the session is killed or not.
do you have full code that we can test?

SA
 
P

Paul

I don't have complete sample code at this time.

I am checking SessionID as well as session variables.

Immediatley after the Add the sesssion is still ok. But then I redirect
to another page and in this new page I see the SessionID is changed and
my variables cleared.

running your test code does not kill the session on my end.

How are you testing if the session is killed or not.
do you have full code that we can test?

SA


I'm having a problem with the session being reset after setting a cookie.
This is not supposed to happen. If I comment out the Add
line below the site works normally, the session persists. Help.

vs2003/.net 1.1

HttpCookie httpCookie = new HttpCookie("myCookieName");
httpCookie.Value = (string)Session["myString"];

// BUG: adding the cookie kills the session.
base.Response.Cookies.Add(httpCookie);
 
M

MSDN

Q: Why does the SessionID changes in every request?
A: This may happen if your application has never stored anything in the
session state. In this case, a new session state (with a new ID) is created
in every request, but is never saved because it contains nothing.

Check out http://www.eggheadcafe.com/articles/20021016.asp

SA

Paul said:
I don't have complete sample code at this time.

I am checking SessionID as well as session variables.

Immediatley after the Add the sesssion is still ok. But then I redirect to
another page and in this new page I see the SessionID is changed and my
variables cleared.

running your test code does not kill the session on my end.

How are you testing if the session is killed or not.
do you have full code that we can test?

SA


I'm having a problem with the session being reset after setting a cookie.
This is not supposed to happen. If I comment out the Add
line below the site works normally, the session persists. Help.

vs2003/.net 1.1

HttpCookie httpCookie = new HttpCookie("myCookieName");
httpCookie.Value = (string)Session["myString"];

// BUG: adding the cookie kills the session.
base.Response.Cookies.Add(httpCookie);
 

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,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top