Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Viewing session variables in browsers

This might be a silly question with an easy answer, but I cannot seem to find any info on it.

I am creating a webapp for a clients intrant, and I am using session variables, which start as they log in.

EG:

Session["ConsultantFirstname"] = adAuth.getFirstName();
Session["ConsultantLastName"] = adAuth.getLastName();

//Then I also have a reader on page load which creates these...

while (reader.Read())
{
    Session["Department"] = reader[1].ToString();
    Session["Channelid"] = reader[2].ToString();
    Session["EmailAddress"] = reader[3].ToString();
    Session["PrimaryTerritory"] = reader[4].ToString();
}

My question is this... How do I see in the browser what session variables have been created? (If I select "Inspect element" > "Resources" > Session storage.. Shouldn't they be there?) I'm quite sure I read a tutorial on this a while ago, but I cannot seem to find it now.

enter image description here

Do I need to add some additional code?

like image 694
Mike Avatar asked Apr 16 '14 07:04

Mike


Video Answer


2 Answers

You cannot view the session state variable at client side. Session state is stored at server, and Client browser only knows SessionID which is stored in cookie or URL.

MSDN says:

Sessions are identified by a unique identifier that can be read by using the SessionID property. When session state is enabled for an ASP.NET application, each request for a page in the application is examined for a SessionID value sent from the browser. If no SessionID value is supplied, ASP.NET starts a new session and the SessionID value for that session is sent to the browser with the response.

By default, SessionID values are stored in a cookie. However, you can also configure the application to store SessionID values in the URL for a "cookieless" session.

Google Chrome provides some extension through which you can edit the cookies.

like image 123
Rahul Tripathi Avatar answered Sep 28 '22 03:09

Rahul Tripathi


try to put print_r($_SESSION); in your code this will print content of $_SESSION variable at that moment.

like image 31
Medo Avatar answered Sep 28 '22 04:09

Medo