Page 1 of 1

Question on Dynamic Cookies

Posted: Sat Oct 25, 2003 4:14 pm
by Zamees
I create cookies and write them to the users PC. The hard coded ones work fine, but when I dynamically create the cookie, some users are not able to have them written in.

I can't say if the reason is because they are dynamic, but I'm looking for possible solutions.

The checker sees if the cookie is null and if so writes the cookie. When the user goes back to this page, its as if the cookie was never written. Why would this be? Only happens for some users?

Posted: Sat Oct 25, 2003 7:20 pm
by Gen-ik
Might be good if you show us some of your cookie code so we can get a better idea of what's going on.

Don't forget that some people have cookies turned off in their browsers, which means no cookies will be saved on their HD once they leave the website or close their browser.

Posted: Sat Oct 25, 2003 8:49 pm
by Zamees

Code: Select all

If Request.Cookies(gamertag_prof)(gamertag_prof) = "" Then 
		Response.Cookies(gamertag_prof)(gamertag_prof) = "voted"
		Response.Cookies (gamertag_prof).Expires = DATE + 3
Thats what ive got to let them access the database. the first time through, it will be null, so it will write the cookie and the next time wont let them into this part. But for some reason some users are able to access it over and over, while most it works fine. There is another cookie that works fairly the same way, so its not that the user has cookies turned off. What else could it be that only affects a few people.

Posted: Sat Oct 25, 2003 9:50 pm
by volka
Zamees wrote:

Code: Select all

If Request.Cookies(gamertag_prof)(gamertag_prof) = "" Then 
		Response.Cookies(gamertag_prof)(gamertag_prof) = "voted"
		Response.Cookies (gamertag_prof).Expires = DATE + 3
that's asp, not php

Posted: Sun Oct 26, 2003 9:49 am
by Derfel Cadarn
IEKKS! I just thought PHP had changed overnight!!

Thanks, Volka, now I can sleep quiet again...

:D

Posted: Mon Oct 27, 2003 3:20 am
by twigletmac
Moved to Miscellaneous due to the reasons stated above :lol:.
Mac

Posted: Mon Oct 27, 2003 8:35 pm
by JAM
I think the correct way to write cookie in ASP is by using this look:

Code: Select all

Request.Cookies("myCookie")
So test one of these:

Code: Select all

// alt 1
   If Request.Cookies("gamertag_prof")("gamertag_prof") = "" Then
      Response.Cookies("gamertag_prof")("gamertag_prof") = "voted"
      Response.Cookies ("gamertag_prof").Expires = DATE + 3

// alt 2
   If Request.Cookies("gamertag_prof") = Empty Then
      Response.Cookies("gamertag_prof")("gamertag_prof") = "voted"
      Response.Cookies ("gamertag_prof").Expires = DATE + 3

// a possible End If perhaps too?
// Request.Cookies("something").HasKeys might be worth looking into also.
Not to fluent in ASP tho, so it's just a shot in the dark.