Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > maintaining control with cookies (not strictly an ASP or even server side question. But not not either)

Reply
Thread Tools

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

 
 
Stephanie Stowe
Guest
Posts: n/a
 
      04-07-2004
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


 
Reply With Quote
 
 
 
 
Stephanie Stowe
Guest
Posts: n/a
 
      04-07-2004
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
>
>



 
Reply With Quote
 
 
 
 
Peter X
Guest
Posts: n/a
 
      04-07-2004
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Not Strictly Java but... Dave Brown Java 0 03-23-2005 11:40 AM
XML control not maintaining contents after postback, even with EnableViewState=true Justin Crossley ASP .Net 0 11-08-2004 03:18 PM
not strictly an asp.net or C# question but?..... Ollie ASP .Net 2 07-15-2004 01:49 PM
not strictly an asp.net or C# question but?..... Ollie ASP .Net Web Services 2 07-15-2004 01:49 PM
not strictly for this group, but I know everyone seems to use it :-) Jonathan Wilson Digital Photography 1 06-23-2004 08:31 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57