maintaining control with cookies (not strictly an ASP or even server side question. But not not eith

Discussion in 'ASP General' started by Stephanie Stowe, Apr 7, 2004.

  1. What I am doing is this... There is a page in my ASP App called "bridge.asp"
    It sets a cookie with the unique ID for some information in a cookie comme
    ca:

    Response.Cookies("MyID") = lngSessionID
    Response.Cookies("MyID").path = "/"
    Response.Cookies("MyID").Domain = "stephie.com"

    In onBody in the ASP page, I change the window location to a URL for a page
    on another server with domain stephie.com (same machine, different port, for
    what that is worth). I do not use a response.redirect because I need the
    page that does the above cookie hoo haa to be what is loaded when the Back
    button is clicked.

    In the second page (JSP), I set another cookie to say that the JSP page has
    been accessed.

    If the cookie already exists, I change the value. Else I add it thus:

    Cookie cookie = new Cookie ("JSPC", "Yes");
    cookie.setDomain("stephie.com");
    cookie.setPath("/");
    response.addCookie(cookie);

    The behavior is that the user starts using an ASP app. They decide to use a
    service available in JSP. When they click the link, it goes to "bridge.asp"
    Bridge.asp has a condition

    If Request.Cookies("JSPC") = "Yes" then
    Response.Cookies("JSPC") = "No"
    DoReturn
    Response.Redirect strLoadPage
    else

    WriteSessionInfo
    WriteIdentifierCookie
    end if

    So the first time to this page, the JSPC cookie is not set at all. So
    WriteSessionInfo is done and WriteIdentifierCookie is done. Then the page
    loads with the window.location change in body on load. The JSP page loads
    and looks lovely. The JSPC cookie is set with the value Yes as above. I
    click the back button, and the bridge.asp sees the JSPC cookie is set to Yes
    and
    sets the JSPC cookie to No. Does DoReturn sub then redirects to LoadPage.

    Now. I do the sequence again. JSPC is set to No. I get properly redirected
    to the JSP page. I can see in my Websphere console that the value of JSPC is
    Yes. I click the back button... The JSPC cookie value is No. So I get sent
    right back to the JSP page.

    The question is (really about cookies).. I set the value in the JSP page of
    JSPC cookie to Yes. When I get back to the ASP page, it thinks the value is
    No.

    Do I have to:

    - set the domain and path of the cookie each time I write its value? If so,
    is there a proper order of operations? I tried this various ways to no
    avail.

    - is there something you can see in this long winded question that I am not
    seeing?

    Thanks

    S
     
    Stephanie Stowe, Apr 7, 2004
    #1
    1. Advertising

  2. Answering my own question, sort of...

    By setting the expiry out into the future, I can see the cookies on disk.
    Yes, cookies. They are 2 different cookies.

    Hmmm.

    S
    "Stephanie Stowe" <> wrote in message
    news:...
    > What I am doing is this... There is a page in my ASP App called

    "bridge.asp"
    > It sets a cookie with the unique ID for some information in a cookie comme
    > ca:
    >
    > Response.Cookies("MyID") = lngSessionID
    > Response.Cookies("MyID").path = "/"
    > Response.Cookies("MyID").Domain = "stephie.com"
    >
    > In onBody in the ASP page, I change the window location to a URL for a

    page
    > on another server with domain stephie.com (same machine, different port,

    for
    > what that is worth). I do not use a response.redirect because I need the
    > page that does the above cookie hoo haa to be what is loaded when the Back
    > button is clicked.
    >
    > In the second page (JSP), I set another cookie to say that the JSP page

    has
    > been accessed.
    >
    > If the cookie already exists, I change the value. Else I add it thus:
    >
    > Cookie cookie = new Cookie ("JSPC", "Yes");
    > cookie.setDomain("stephie.com");
    > cookie.setPath("/");
    > response.addCookie(cookie);
    >
    > The behavior is that the user starts using an ASP app. They decide to use

    a
    > service available in JSP. When they click the link, it goes to

    "bridge.asp"
    > Bridge.asp has a condition
    >
    > If Request.Cookies("JSPC") = "Yes" then
    > Response.Cookies("JSPC") = "No"
    > DoReturn
    > Response.Redirect strLoadPage
    > else
    >
    > WriteSessionInfo
    > WriteIdentifierCookie
    > end if
    >
    > So the first time to this page, the JSPC cookie is not set at all. So
    > WriteSessionInfo is done and WriteIdentifierCookie is done. Then the page
    > loads with the window.location change in body on load. The JSP page loads
    > and looks lovely. The JSPC cookie is set with the value Yes as above. I
    > click the back button, and the bridge.asp sees the JSPC cookie is set to

    Yes
    > and
    > sets the JSPC cookie to No. Does DoReturn sub then redirects to LoadPage.
    >
    > Now. I do the sequence again. JSPC is set to No. I get properly redirected
    > to the JSP page. I can see in my Websphere console that the value of JSPC

    is
    > Yes. I click the back button... The JSPC cookie value is No. So I get sent
    > right back to the JSP page.
    >
    > The question is (really about cookies).. I set the value in the JSP page

    of
    > JSPC cookie to Yes. When I get back to the ASP page, it thinks the value

    is
    > No.
    >
    > Do I have to:
    >
    > - set the domain and path of the cookie each time I write its value? If

    so,
    > is there a proper order of operations? I tried this various ways to no
    > avail.
    >
    > - is there something you can see in this long winded question that I am

    not
    > seeing?
    >
    > Thanks
    >
    > S
    >
    >
     
    Stephanie Stowe, Apr 7, 2004
    #2
    1. Advertising

  3. Stephanie Stowe

    Peter X Guest

    Re: maintaining control with cookies (not strictly an ASP or evenserver side question. But not not either)

    Stephanie Stowe wrote:

    > Answering my own question, sort of...
    >
    > By setting the expiry out into the future, I can see the cookies on disk.
    > Yes, cookies. They are 2 different cookies.
    >


    Hi Stephanie,

    I've only briefly looked at your posts (so if I've completely
    misunderstood then... oops!), but I _think_ the reason you're getting
    two cookies it because you're writting out a cookie:

    >>Response.Cookies("MyID") = lngSessionID
    >>Response.Cookies("MyID").path = "/"
    >>Response.Cookies("MyID").Domain = "stephie.com"


    ...but ASP normally tracks sessions using its own cookies that it sends
    to the client without you needing to do anything.

    That should explain the two cookies thing!

    As for the cookie you're writting out, what is *lngSessionID* ?

    And how do you intend tieing that back up with a session? What I mean
    here is, assuming lngSessionID is a unique ID for the current Session
    object, then how did you plan to read the cookie and get the session
    object back?

    This is _why_ ASP manages sesions and their cookies for you -- when the
    client makes a request, if they supply a session cookie then the correct
    Session object will be found and passed to the page script being run. Or
    something like that anyways.


    A further question is, what is it that you're storing that you need to
    track it in a session? This is important, since the session only lasts a
    finite amount of time anyway (by default 20 minutes), so if you've got
    users going off to do something on the JSP server, are they likely to be
    away for more than 20 minutes?

    Hope that helps a little... although I think I'm asking more questions
    than answering!

    --
    Peter.
     
    Peter X, Apr 7, 2004
    #3
    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. Ollie
    Replies:
    2
    Views:
    629
    Ollie
    Jul 15, 2004
  2. Justin Crossley
    Replies:
    0
    Views:
    450
    Justin Crossley
    Nov 8, 2004
  3. Dave Brown

    Not Strictly Java but...

    Dave Brown, Mar 23, 2005, in forum: Java
    Replies:
    0
    Views:
    353
    Dave Brown
    Mar 23, 2005
  4. Ollie

    not strictly an asp.net or C# question but?.....

    Ollie, Jul 15, 2004, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    177
    Ollie
    Jul 15, 2004
  5. Frances Del Rio

    not strictly a JS question, but....

    Frances Del Rio, Sep 26, 2004, in forum: Javascript
    Replies:
    7
    Views:
    245
    Richard Cornford
    Oct 11, 2004
Loading...

Share This Page