Session Data Problem

Posted on 2007-07-31
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:


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?
Question by:quanmac
    LVL 37

    Accepted Solution

    if you do:

    what does it return?

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

    Expert Comment

    Are you setting up the Session["EmpId"].= "10002" after successfully log in to the system?
    LVL 3

    Author Comment

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

    Author Comment

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

    That Worked

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
    For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    760 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

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now