Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session and / or cookie lost when opening new window 1

Status
Not open for further replies.

inspiraller

Programmer
Nov 16, 2004
23
GB
Hello

1) PAGE 1 - I have created either Session("loggedin")="true" OR Response.Cookies("loggedin")="true"

2) PAGE 2 - LOOPS and writes ALL Sessions and cookies (This works fine)

START SESSION LOOP
loggedin=true
END SESSION LOOP

START COOKIES LOOP
loggedin=true
END COOKIES LOOP

3) I open up a new brower window by typing in the url for PAGE 2, and the Session and Cookie does not display anything. They dont exist?

START SESSION LOOP
END SESSION LOOP
START COOKIES LOOP
END COOKIES LOOP


NOTE: I have even tried setting an expire and domain for cookie just to be thorough and that doesnt work either.

Can anybody explain to me how I can get my cookie recognised when opening a new window from a seperate url, or from typing it in?
 
A new browser window is a new session. Ergo, you will not see anything from your previous session because the new window is a new session (I am assuming that you are manually opening a new browser window and not doing it through code).

------------------------------------------------------------------------------------------------------------------------
If you don't have a sense of humor, you probably don't have any sense at all.
- Anonymous
 
This may offer some additional information on session objects in general. Session Objects

------------------------------------------------------------------------------------------------------------------------
If you don't have a sense of humor, you probably don't have any sense at all.
- Anonymous
 
Hello Chopstick, and thanks for your response. I understnd that about the session, so I have created a cookie instead. Hence, im wondering why its not even recognising the cookie?
 
Ok, sorry about that. I misunderstood the question. Specifically how are you attempting to set the cookie in the first page and how are you attempting to retrieve it in the second page? This may help to more specifically track your problem down.

------------------------------------------------------------------------------------------------------------------------
If you don't have a sense of humor, you probably don't have any sense at all.
- Anonymous
 
PAGE 1

Response.Cookies("loggedin")="true"
Response.Cookies("loggedin").Expires = Date + 1
Response.Cookies("loggedin").Domain = strMyDomain

PAGE 2

Response.Write wrapLine("START COOKIES LOOP")
for each itemName in Request.Cookies
Response.Write wrapLine(itemName & "=" & Request.Cookies(itemName))
next
Response.Write wrapLine("END COOKIES LOOP")

 
Am not an expert with cookies (especially since I just learned about the .domain attribute that of which I was previously unaware), but what you have appears fine to me. Just a minor change to test, but can you set the .expires = Now() + 5 and then test it? Also, I am assuming that you are able to view everything in the original browser just fine, you only encounter the problem when opening in a new window? Is your original browser window still open (not that it should cause the problem, mind you, just a thought...)?

And are you able to write any other cookies, or is it just this one that you have a problem with?

------------------------------------------------------------------------------------------------------------------------
If you don't have a sense of humor, you probably don't have any sense at all.
- Anonymous
 
Yes, I can view the cookie from the original page, and if i traverse pages from the initial setting of the cookie. But the cookie is not there, when opening a new window.

I have even tried setting the cookie with Now + 5 and the cookie is still not there when opening a new window.
 
Based on what you've explained and my own (limited) knowledge, it should work. Sorry, but I cannot think of a reason at the moment that it fails... Wish I could be of more assistance...

------------------------------------------------------------------------------------------------------------------------
If you don't have a sense of humor, you probably don't have any sense at all.
- Anonymous
 
I have sorted it. It wasnt working because I put http:// in my domain name http://

Thanks anyway chopstik.

 
So, it failed because you were setting the domain with the http:// protocol? But it worked when you take it out... Interesting, and something that I'll be mentally filing away... BTW, Thanks for your posting your answer in case others find the same problem.
[thumbsup]

------------------------------------------------------------------------------------------------------------------------
If you don't have a sense of humor, you probably don't have any sense at all.
- Anonymous
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top