Forum Moderators: open

Message Too Old, No Replies

what is the Session Cookie called?

         

txbakers

1:38 pm on Oct 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would like to find and open the cookie created by the Session object, but I can't seem to locate it.

Does anyone know what it is called?

Easy_Coder

5:06 pm on Oct 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



txbakers, I think it shows up on the client as username@domain.txt; leave a browser window open to that site while you go digging for the cookie

john_k

5:18 pm on Oct 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For ASP, the name varies. It always starts with ASPSESSIONID followed by another string. I believe that the second half string is unique to the application instance.

For .Net, it appears to be ASP.NET_SessionId. I have never had a reason to look into this one much, though, so there might be some configuration settings that would change it.

In either case, these should show up in your log files if you have "extended logging" with "cookies" enabled for the website.

Easy_Coder

5:44 pm on Oct 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



john_k, the cookie doesn't show up that way on the client does it? I though that (ASPSESSIONID) was on the server side?

txbakers

6:05 pm on Oct 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, I'm looking for it on the client side - in the client's Cookies folder.

I did open the folder, then logged into the site, and there was no change in the folder. So I'm wondering where I could find it, and what it would be called.

john_k

6:22 pm on Oct 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't think you will find the session id in the persisted cookie file.

There should be a way to loop through all of the cookies with javascript. One of the O'Reilly javascript books has an excellent section on cookies. However, my copy is at home and I am not. I'll check back here tonight to see if you've found a solution. If not, I'll see what I can find in the O'Reilly book. (sorry, I don't recall the title - and it is about 7 years old)

txbakers

7:26 pm on Oct 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't need the session Id itself, I just want to find the cookie created by the Session object.

john_k

7:37 pm on Oct 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't need the session Id itself, I just want to find the cookie created by the Session object.

right - I am thinking that you could grab the cookie names.

At any rate, since I posted the previous response, I have realized that I know of another way to get it. But once again, the code sample is at home. I will post it in a few hours.

john_k

10:04 pm on Oct 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Okay, it sends both the ASP and .Net Session cookies as I had posted before.

You can use the ASP script below to fetch any web page. Any cookies from the server will show up amongst the HTTP headers.

Paste the code into a new ASP page and then run it. Enter the URL to a known ASP web page to see the headers returned by the server. (if you run it against a page on the same machine, you may run into permissions and/or dns issues, so pick a remote page)

The headers for an ASP page will include something like this:
Set-Cookie: ASPSESSIONIDCCDQTDAR=LABKDGLAMJPKNGENFPBHMPCK; path=/

The headers for an ASPX page will include something like this:
Set-Cookie: ASP.NET_SessionId=gfqpmpu3mknuoqac3ajk5z45; path=/

Please note that this is an old script. And as written, it utilizes MSXML2.XMLHTTP. You may need to swap in a different component (and modify some code accordingly).


<%@ Language=VBScript %>
<%
Dim objHTTP
Dim sHTML
Dim sHeaders
Dim sResponse
Dim sLocation
Dim sURL
Dim bHeadersOnly
Dim sHeadersChecked

sURL = Request("txtURL")
If Len(sURL) > 0 Then
sURL = Trim(sURL)
Else
sURL = ""
End If
bHeadersOnly = (CLng(Request("chkheadersonly")) = 1)
If bHeadersOnly Then
sHeadersChecked = " checked=""checked"""
Else
sHeadersChecked = ""
End If

If sURL <> "" Then
If LCase(Left(sURL, 7)) <> "http://" Then
sURL = "http://" & sURL
End If
Set objHTTP = Server.CreateObject("MSXML2.XMLHTTP")
objHTTP.open "GET", sURL, False
objHTTP.send
sHeaders = objHTTP.getAllResponseHeaders
If bHeadersOnly Then
sResponse = ""
Else
sResponse = objHTTP.responseText
End If
Set objHTTP = Nothing
sURL = Mid(sURL, 8)
Else
sResponse = ""
End If
%>
<html>
<head>
<title>Get Page Info</title>
</head>
<body>
<form name="frmUrl" method="POST" action="ServerHeaders2.asp">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>URL to check:</td>
<td>&nbsp;</td>
<td><input type="TEXT" name="txtUrl" value="<%= sURL %>" size="45"></td>
<td>&nbsp;</td>
<td><input type="SUBMIT" value="Get HTML" id=SUBMIT1></td>
</tr>
<tr>
<td colspan="2"></td>
<td align="center"><input type="checkbox" name="chkheadersonly" value="1"<%= sHeadersChecked %>> headers only</td>
</tr>
</table>
</form><hr />
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><strong>HTTP Headers</strong></td>
</tr>
<tr>
<td bgcolor="#dddddd">
<pre><%= Server.HTMLEncode(sHeaders) %></pre>
</td>
</tr>
</table>
<% If Not bHeadersOnly Then %>
<table border="0" cellspacing="0" cellpadding="0">
<tr><td>&nbsp;<br /></td></tr>
<tr>
<td><strong>HTML</strong></td>
</tr>
<tr>
<td bgcolor="#dddddd">
<pre><%= Server.HTMLEncode(sResponse) %></pre>
</td>
</tr>
</table>
<% End If %>
</BODY>
</HTML>