Solved

request.ServerVariables("HTTP_COOKIE") weird problem

Posted on 2004-10-27
1,048 Views
Last Modified: 2008-01-09
Every now and again, as an IT professional, you come across problems that defy all logical explanations, and make you ask yourself - "Is someone f***ing with me?"

Anyways, here is a problem I am facing as such:

In my asp page, request.ServerVariables("HTTP_COOKIE") is returning two separate cookie names, obviously causing me problems.  

Instead of returning just ASPSESSIONIDCSAADRAA=DKPHNFLAEDGJCHBDJLGGOAKD

it returns
ASPSESSIONIDCSAADRAA=DKPHNFLAEDGJCHBDJLGGOAKD; ASPSESSIONIDCSCBDRAA=GHDPHAJBKGJNFKOJJCNFFNKMSELECT

and YES, that semicolon is part of the string.

In my code, this is all i am doing:

tmpTable1 = request.ServerVariables("HTTP_COOKIE")

and then i use tmpTable1 throughout the page.


Finest wines and cheeses to anyone who solves this!
0
Question by:TWBit
    4 Comments
     
    LVL 5

    Expert Comment

    by:jpontani
    Just split the string on the semicolon.

    tmpStr = request.ServerVariables("HTTP_COOKIE")
    cookieArray = Split(tmpStr, ";")

    You can then loop through the array to check for the one you want (in this case it will be item 1)

    tmpTable1 = cookieArray(0)
    0
     
    LVL 11

    Author Comment

    by:TWBit
    Yeah, I was going to resort to string manipulation if all else fails, but what I would like to know is why its returning 2 cookie values.  Any ideas?
    0
     
    LVL 32

    Accepted Solution

    by:
    Althoough it is not covered anywhere extensively, the HTTP_COOKIE value depends entirely on what the *browser* sends back.  This entry indicates to me that the browser PC has two active (or not deleted) session cookies related to the requestor site.

    If you are doing this from a test PC, try clearing out all cookies in your browser, and try again.  You should only get one value back.
    0
     
    LVL 11

    Author Comment

    by:TWBit
    Yup, thats the ticket.  Thanks!
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
    Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
    Via a live example, show how to shrink a transaction log file down to a reasonable size.
    Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

    911 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now