p byers said:
Hi Folks
I have seen a method of obtaining all of the SESSION (or COOKIES maybe)
using a "for each" statement.
BUT
I have forgotten how/when/where I saw it.
I am particularly interested in the "automatically generated long
unique string Session Identifier"
Please forgive my "No-Tech" description of what I require - I fear
Senile Decay is happening quicker than I thought.
If you run the code posted elsewhere in this thread you'll get list of the
current cookies in the request. You'll notice though that the one cookie
that you're actually after is missing. It is consumed by ASP in order to
included the correct session object in the script context and is not made
available in the Request.Cookies collection.
You can see it thougn in this:-
Response.Write Request.ServerVariables("HTTP_COOKIE")
But this is simplye the cookie header value in full so will contain all
cookies for the currently location unparsedd.
You could extract it with some Regex:-
Dim sCookieHeader : sCookieHeader = Request.ServerVariables("HTTP_COOKIE")
Dim rgx : Set rgx = NewRegExp("ASPSESSIONID([A-Z0-9]+)=([A-Z0-9]+)", True,
True)
Dim oMatch
For Each oMatch in rgx.Execute(sCookieHeader)
Response.Write oMatch.Value & "<br />"
Response.Write "App Instance: " & oMatch.SubMatches(0) & "<br />"
Response.Write "Session Code: " & oMatch.SubMatches(1) & "<br />"
Next
Function NewRegExp(rsPattern, rbGlobal, rbCaseInsensitive)
Set NewRegExp = new RegExp
NewRegExp.Pattern = rsPattern
NewRegExp.Global = rbGlobal
NewRegExp.IgnoreCase = rbCaseInsensitive
End Function
However if you were to unload the app or recycle the app pool you will start
to see multiple ASPSESSIONIDxxxxx headers. I guess you will need to know
which is the current one, its guess because I'm not sure how any of this
would be useful?