Question on Dynamic Cookies

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
Zamees
Forum Newbie
Posts: 19
Joined: Mon Oct 06, 2003 11:27 am

Question on Dynamic Cookies

Post 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?
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post 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.
Zamees
Forum Newbie
Posts: 19
Joined: Mon Oct 06, 2003 11:27 am

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
User avatar
Derfel Cadarn
Forum Contributor
Posts: 193
Joined: Thu Jul 17, 2003 12:02 pm
Location: Berlin, Germany

Post by Derfel Cadarn »

IEKKS! I just thought PHP had changed overnight!!

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

:D
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Moved to Miscellaneous due to the reasons stated above :lol:.
Mac
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post 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.
Post Reply