Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 13, 2012 03:43 PM by Rion Williams
Member
41 Points
91 Posts
Apr 13, 2012 03:05 PM|LINK
Hello. I have a 5 hours searching problem...All my login data inside session is lost. In SignIn i have:
Session.RemoveAll(); Session["customer"] = customer;
Response.Redirect("/Order");
The customer is added in session but after redirect, when i chck in Order if it is there, my session is null. What should i do?
In order i have i am using:
if (HttpContext.Current.Session["customer"] != null) - wich is always null
All-Star
27794 Points
4595 Posts
Apr 13, 2012 03:13 PM|LINK
The Session may not be migrating across the two areas - and the Redirect could be the culprit.
Bertrand Le Roy discusses this same topic in his blog and why not to use Redirects after manipulating the Session:
Bertrand Le Roy : Don't Redirect After Session Variable Changes
He presents two solutions - the first, which applies to FormsAuthentication, uses an already predefined to handle this very purpose:
FormsAuthentication.RedirectFromLoginPage("/Order")
The other solution is to overload the original version of the Redirect method, by passing false as the second parameter:
Request.Redirect("/Order",false);
Apr 13, 2012 03:28 PM|LINK
I tryed many times this, but i seems only copy-paste from you worked :) Thank you very much!
Apr 13, 2012 03:43 PM|LINK
I'm glad it helped fixed your issue :)
seiko88
Member
41 Points
91 Posts
Session variable login lost
Apr 13, 2012 03:05 PM|LINK
Hello. I have a 5 hours searching problem...All my login data inside session is lost. In SignIn i have:
Session.RemoveAll();
Session["customer"] = customer;
Response.Redirect("/Order");
The customer is added in session but after redirect, when i chck in Order if it is there, my session is null. What should i do?
In order i have i am using:
if (HttpContext.Current.Session["customer"] != null) - wich is always null
Rion William...
All-Star
27794 Points
4595 Posts
Re: Session variable login lost
Apr 13, 2012 03:13 PM|LINK
The Session may not be migrating across the two areas - and the Redirect could be the culprit.
Bertrand Le Roy discusses this same topic in his blog and why not to use Redirects after manipulating the Session:
Bertrand Le Roy : Don't Redirect After Session Variable Changes
He presents two solutions - the first, which applies to FormsAuthentication, uses an already predefined to handle this very purpose:
FormsAuthentication.RedirectFromLoginPage("/Order")The other solution is to overload the original version of the Redirect method, by passing false as the second parameter:
Request.Redirect("/Order",false);seiko88
Member
41 Points
91 Posts
Re: Session variable login lost
Apr 13, 2012 03:28 PM|LINK
Rion William...
All-Star
27794 Points
4595 Posts
Re: Session variable login lost
Apr 13, 2012 03:43 PM|LINK
I'm glad it helped fixed your issue :)