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

  • Thread starter Stephanie Stowe
  • Start date
S

Stephanie Stowe

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
 
S

Stephanie Stowe

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
 
P

Peter X

Stephanie said:
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:

...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!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top