Creating cookies in Global.asa Session_OnStart but cannot read cookies on subsequent pages.

Discussion in 'ASP General' started by bb, Sep 15, 2004.

  1. bb

    bb Guest

    Hello

    In my Session_OnStart in Global.asa, I am setting some cookies. One
    of them, I set as follows:

    dim UserID
    UserID = Request.ServerVariables("LOGON_USER")
    Response.Cookies("User")("ID") = UCASE(UserID)

    When I immediately log the cookie value retrieved from
    Request.Cookies("User")("ID") into the Windows Event Log, I get the
    correct value. However, when I try to retrieve the cookie on the home
    page of my application using the same code,
    Request.Cookies("User")("ID"), it either cannot find the cookie or
    cannot read the value. I am retrieving the cookie before all HTML
    headers are written. It is my first statement on the page after
    Option Explicit. I have even compared the session IDs. The SessionID
    created in the Session_OnStart is the same value as the SessionID on
    the home page.

    I have read that the Session_OnStart only has access to the
    Application, Session and Request objects. It does not explicitly say
    that it does not have access to the Response object. Also, I was even
    able to use Response.Write's in Global.asa to print out the values
    although it looked like it had also stopped the session after I did
    so. Cookies are definitely enabled on my machine. I have even tried
    setting the session cookie's expiration to be persistent for a few
    days to see if it was perhaps expiring before I was able to read it
    but this did not work either.

    Is there something preventing cookies to be created in Global.asa in
    the Session_OnStart sub? Is the Response object not available???
    Please let me know if anyone else has had this problem or solution.

    Thanks.
     
    bb, Sep 15, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wayne
    Replies:
    2
    Views:
    478
    Wayne
    Nov 11, 2003
  2. Replies:
    2
    Views:
    799
  3. Grahammer
    Replies:
    12
    Views:
    346
    Chris Hohmann
    Aug 21, 2003
  4. Cookies in global.asa

    , Jun 24, 2004, in forum: ASP General
    Replies:
    4
    Views:
    439
    Zenobia
    Jun 26, 2004
  5. Amit D.Shinde
    Replies:
    2
    Views:
    197
    Bã§TãRÐ
    Jul 27, 2004
Loading...

Share This Page