Link to home
Start Free TrialLog in
Avatar of quanmac
quanmac

asked on

Session Data Problem

Hi there,

I have a website, when someone logs in, I create a Session variable for the id of the person who logged in. When they logout, I run these lines of code:

FormsAuthentication.SignOut();
Response.Cookies.Clear();
Session.Clear();
Session.RemoveAll();
Context.Application.RemoveAll();

And when I log in as another user, the session variable does something weird. It logs in and the Session variable gets created, but when I run  this code on  my Navigation.ascx control:
<%
                if (Session["EmpId"].ToString().Equals("10002"))
                {
                    Response.Write("<b><a href='AdminPage.aspx'>Task Setup Page</a></b><br><br><br>");
                }
%>

It doesn't catch that id, even though I logged in as EmpId 10002.

Anyone have any idea on why this is happening or how I can fix this?
ASKER CERTIFIED SOLUTION
Avatar of samtran0331
samtran0331
Flag of United States of America 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
Are you setting up the Session["EmpId"].= "10002" after successfully log in to the system?
Avatar of quanmac
quanmac

ASKER

Yes, after the person logs in, they get forwarded to their profile page, and the page reads the Session["EmpId"] value
Avatar of quanmac

ASKER

if (Session["EmpId"].ToString == "10002")

That Worked