?
Solved

Session Data Problem

Posted on 2007-07-31
4
Medium Priority
?
187 Views
Last Modified: 2013-12-17
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?
0
Comment
Question by:quanmac
  • 2
4 Comments
 
LVL 37

Accepted Solution

by:
samtran0331 earned 2000 total points
ID: 19603830
if you do:
Response.Write(Session["EmpId"].ToString());

what does it return?

have you tried doing:
if (Session["EmpId"].ToString == "10002")
instead of:
if (Session["EmpId"].ToString().Equals("10002"))
0
 
LVL 8

Expert Comment

by:sabeesh
ID: 19603855
Are you setting up the Session["EmpId"].= "10002" after successfully log in to the system?
0
 
LVL 3

Author Comment

by:quanmac
ID: 19604219
Yes, after the person logs in, they get forwarded to their profile page, and the page reads the Session["EmpId"] value
0
 
LVL 3

Author Comment

by:quanmac
ID: 19608759
if (Session["EmpId"].ToString == "10002")

That Worked
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month14 days, 15 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question