Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > I forgot, help please

Reply
Thread Tools

I forgot, help please

 
 
p byers
Guest
Posts: n/a
 
      01-19-2008
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.

Best regards
Thank you
Pete (Northolt UK)



 
Reply With Quote
 
 
 
 
p byers
Guest
Posts: n/a
 
      01-19-2008
Should have said "Using ASP on the Server"

p byers wrote:

> 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.
>
> Best regards
> Thank you
> Pete (Northolt UK)


 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      01-19-2008
About half way down.
http://www.angelfire.com/tx4/cus/notes/asp.html

I add this one, as I like the way he has formatted his code. It is very easy
to read and understand.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box!
|
*************************************************
"p byers" <> wrote in message
news:...
> 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.
>
> Best regards
> Thank you
> Pete (Northolt UK)
>
>
>



 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      01-19-2008
"Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot com> wrote in message
news:...
> google is your friend....
>
> <%
> 'Print out the entire cookie collection.
> '-----------------------------------------
> For Each cookie in Request.Cookies
> If Not cookie.HasKeys Then
> 'Print out the cookie string
> %>
> <%= cookie %> = <%= Request.Cookies(cookie)%>
> <%
> Else
> 'Print out the cookie collection
> '------------------------------------------
> For Each key in Request.Cookies(cookie)
> %>
> <%= cookie %> (<%= key %>) = <%= Request.Cookies(cookie)(key)%>
> <%
> Next
> End If
> Next
> %>
>


Close but no banana.

Try:-

Dim cookie, key, subKey
Dim i
'Print out the entire cookie collection.
'-----------------------------------------
For Each key in Request.Cookies
Set cookie = Request.Cookies(key)
If Not cookie.HasKeys Then
'Print out the cookie string
%>
<%=key %> = <%=cookie%><br />
<%
Else
'Print out the cookie collection
'------------------------------------------
For Each subKey in cookie
%>
<%= key %> (<%= subKey %>) = <%= cookie(subKey)%><br />
<%
Next
End If
Next


--
Anthony Jones - MVP ASP/ASP.NET


 
Reply With Quote
 
p byers
Guest
Posts: n/a
 
      01-19-2008
Thank you both for you quick helpful replies
Pete (Northolt UK)

p byers wrote:

> 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.
>
> Best regards
> Thank you
> Pete (Northolt UK)


 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      01-19-2008
"p byers" <> wrote in message
news:...
> 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?



--
Anthony Jones - MVP ASP/ASP.NET


 
Reply With Quote
 
Daniel Crichton
Guest
Posts: n/a
 
      01-21-2008
Anthony wrote on Sat, 19 Jan 2008 22:23:58 -0000:

> "p byers" <> wrote in message
> news:...
>> 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?



Doesn't

Response.Write Session.SessionID

return the appropriate session ID value that is currently in use (assuming
that sessions are enabled of course).

--
Dan


 
Reply With Quote
 
Daniel Crichton
Guest
Posts: n/a
 
      01-21-2008
Daniel wrote to Anthony Jones on Mon, 21 Jan 2008 13:38:05 -0000:

> Anthony wrote on Sat, 19 Jan 2008 22:23:58 -0000:


>> "p byers" <> wrote in message
>> news:...
>>> 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?



> Doesn't


> Response.Write Session.SessionID


> return the appropriate session ID value that is currently in use
> (assuming that sessions are enabled of course).


Sorry for not posting a complete reply.

Anyway, once you've got the value of Session.SessionID, you should then be
able to compare it's value to the ASPSESSIONIDxxxxx values and find the
correct one, assuming that you don't have two with the same value (which
shouldn't happen normally, but there's always a chance).

--
Dan


 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      01-21-2008
"Daniel Crichton" <> wrote in message
news:...
> Daniel wrote to Anthony Jones on Mon, 21 Jan 2008 13:38:05 -0000:
>
> > Anthony wrote on Sat, 19 Jan 2008 22:23:58 -0000:

>
> >> "p byers" <> wrote in message
> >> news:...
> >>> 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?

>
>
> > Doesn't

>
> > Response.Write Session.SessionID

>
> > return the appropriate session ID value that is currently in use
> > (assuming that sessions are enabled of course).

>
> Sorry for not posting a complete reply.
>
> Anyway, once you've got the value of Session.SessionID, you should then be
> able to compare it's value to the ASPSESSIONIDxxxxx values and find the
> correct one, assuming that you don't have two with the same value (which
> shouldn't happen normally, but there's always a chance).
>


Its a good point. I was working on the assumption that SessionID is not
useful for some reason. I didn't occur to me that the OP may not be aware of
its existance.

I'm not sure why there would be any need to compare it to the cookie value
though. Also I'm not sure how or even if its possible to map the value of
SessionID to the cooke value.

--
Anthony Jones - MVP ASP/ASP.NET


 
Reply With Quote
 
Daniel Crichton
Guest
Posts: n/a
 
      01-22-2008
Anthony wrote on Mon, 21 Jan 2008 21:57:23 -0000:

> "Daniel Crichton" <> wrote in message
> news:...
>> Daniel wrote to Anthony Jones on Mon, 21 Jan 2008 13:38:05 -0000:


>>> Anthony wrote on Sat, 19 Jan 2008 22:23:58 -0000:


>>>> "p byers" <> wrote in message
>>>> news:...
>>>>> 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?



>>> Doesn't


>>> Response.Write Session.SessionID


>>> return the appropriate session ID value that is currently in use
>>> (assuming that sessions are enabled of course).


>> Sorry for not posting a complete reply.


>> Anyway, once you've got the value of Session.SessionID, you should
>> then be able to compare it's value to the ASPSESSIONIDxxxxx values
>> and find the correct one, assuming that you don't have two with the
>> same value (which shouldn't happen normally, but there's always a
>> chance).



> Its a good point. I was working on the assumption that SessionID is not
> useful for some reason. I didn't occur to me that the OP may not be
> aware of its existance.


> I'm not sure why there would be any need to compare it to the cookie
> value though. Also I'm not sure how or even if its possible to map the
> value of
> SessionID to the cooke value.


Given that you can parse the HTTP_COOKIE header, and so extract the values
for each ASPSESSIONIDxxxxxx cookie, and using the value of .SessionID, you
should then be able to find the ASPSESSIONIDxxxxxx cookie that is passing
the SessionID. Whether this is useful to know or not is anyone's guess

But at least there is a way of getting the "automatically generated long
unique string Session Identifier" that the OP was asking for, which should
be Session.SessionID.

--
Dan


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please please please help this guy with his open source java app casioculture@gmail.com Java 4 05-05-2005 08:24 AM
Console profile for Windows app in VC++ - PLEASE PLEASE PLEASE HELP! MuZZy C++ 7 01-07-2005 08:40 PM
Computer problems please please please help Nick Computer Support 0 06-04-2004 08:49 PM
HELP! HELP! PLEASE, PLEASE, PLEASE tpg comcntr Computer Support 11 02-15-2004 06:22 PM
please help... ...me learn C++ please please please :) KK C++ 2 10-14-2003 02:08 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57