Help with session

M

Maziar Aflatoun

Hi,

I'm writing a second user login for our website. I have a login page which
sets a session value and redirects the user back.

I have the following in the login page.

Session["UserID"]=UserID;
Session.Add("isAuthenticated",true);
System.Diagnostics.Debug.WriteLine("UserID:"+
Session["UserID"].ToString()); // works
Response.Redirect(ReturnURL);


However, in the return page the value becomes null
try
{
Response.Write("isAuthenticated:" + Session["UserID"].ToString() +
"<br>");
}
catch
{
Response.Write("isAuthenticated is empty<br>");
}

Any suggestions?

Thanks
Maz
 
L

Lucas Tam

Hi,

I'm writing a second user login for our website. I have a login page
which sets a session value and redirects the user back.

I have the following in the login page.

Session["UserID"]=UserID;
Session.Add("isAuthenticated",true);
System.Diagnostics.Debug.WriteLine("UserID:"+
Session["UserID"].ToString()); // works
Response.Redirect(ReturnURL);


Are both sites under the same app name?
 
M

Maziar Aflatoun

They are.. also if I remove Response.Redirect(ReturnURL) line and go to the
request page, it works fine. So I guess it's the response.redirect that's
causing it. Any idea?

Lucas Tam said:
Hi,

I'm writing a second user login for our website. I have a login page
which sets a session value and redirects the user back.

I have the following in the login page.

Session["UserID"]=UserID;
Session.Add("isAuthenticated",true);
System.Diagnostics.Debug.WriteLine("UserID:"+
Session["UserID"].ToString()); // works
Response.Redirect(ReturnURL);


Are both sites under the same app name?
 
T

tom pester

Uhm very strange. Your code looks absolutly normal and a response.redirict
isn't a bad boy in general.

Can you post the 2 pages so we can repro?

Let me know if you have any more questions...

Cheers,
Tom Pester
They are.. also if I remove Response.Redirect(ReturnURL) line and go
to the request page, it works fine. So I guess it's the
response.redirect that's causing it. Any idea?

Maziar Aflatoun said:
Hi,

I'm writing a second user login for our website. I have a login
page which sets a session value and redirects the user back.

I have the following in the login page.

Session["UserID"]=UserID;
Session.Add("isAuthenticated",true);
System.Diagnostics.Debug.WriteLine("UserID:"+
Session["UserID"].ToString()); // works
Response.Redirect(ReturnURL);
Are both sites under the same app name?
 

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

Similar Threads


Top