Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

server variables HTTP_COOKIE

Status
Not open for further replies.

jimberger

Programmer
Jul 5, 2001
222
GB
Hello all,

I am trying to request the server variable HTTP_COOKIE as it gives me a unique ID for the browser session which i am storing in a database. However, sometimes and on different machines this value is not set and therefoe my SQL statement crashes. Does anybody know why this value is sometimes not set or does anybody know another way of retreiving a unique session id from a server variables.

thanks for your help
jim
 

Session.SessionID

Although it is a pseudo-random ID number which will be unique for the duration of its use, it is not guaranteed to be permanently unique, so it should only be used in the scope of the session and not as a permanent UID.




A smile is worth a thousand kind words. So smile, it's easy! :)
 
Hello,

The problem i'm having is that i am creating a session in a ASP page which stores the users log on details. However i need to use this session in a asp.net page. But the two session obejcts are different. my thought process was that i could save the details to a database and use the HTTP_COOKIE as the key to retrieve the information once in the ASP.NET page. The problem is that sometimes the HTTP_COOKIE is not set and therefore my database query fails.

any ideas on how i can get around this?
thanks for your time
 

On the occasions that the HTTP_COOKIE is not set, can you predict the scenario ? i.e. is it for computers with cookies turned off (session cookies), or is it a particular OS etc ?

Do a quick test of adding a custom cookie to the response for the scenario where this doesn't work - then do a dump of the HTTP_COOKIE server variable. If you can see your custom variable but not the ASPSESSIONIDxxxxxx=xxxxxxxxxxxxxxxx then there could be a fault with IIS - we would need to do more tests.

Also, try dumping the entire HTTP header..

response.write(request.servervariables("ALL_RAW"))

see if that contains the ASPSESSIONID variable.

The simple alternative is to pass the ID, or a temp ID, to the aspx page via the querystring - although a 'miniscule' amount less secure - not a huge problem.



A smile is worth a thousand kind words. So smile, it's easy! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top