cookies set in PHP vs. JavaScript

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

brownie124
New php-forum User
New php-forum User
Posts: 23
Joined: Thu Feb 13, 2003 1:58 pm
Location: Peterborough, NH

cookies set in PHP vs. JavaScript

Postby brownie124 » Wed Jun 11, 2003 1:03 pm

Are these the same? That is to say that if in one php file I did a document.cookie = "foo=1", then opened another php file in another window, would $_COOKIE['foo'] be 1?

I am asking this because I am not seeing this.

If PHP cookies aren't as dynamic as JavaScript cookies, what good are they?

More strange behavior on this:

In one PHP file I am doing
setcookie("wincount", "1", 0, "", "");

I eventually fire up another php file from the same window. In there I do:
@print($_COOKIE['wincount']);
It returns 0. However, I then do an alert(myGetCookieData('wincount')) in a function that is fired on the onload event and it returns 1.

That makes no sense.

Thanks,
- Michael

brownie124
New php-forum User
New php-forum User
Posts: 23
Joined: Thu Feb 13, 2003 1:58 pm
Location: Peterborough, NH

Fixed it

Postby brownie124 » Wed Jun 11, 2003 1:59 pm

It had something to do with the variable name wincount. I am not sure what. I have no explanation really. All I know is that I changed the name and it worked fine.

Is wincount some kind of internal variable to PHP?

- Michael

User avatar
WiZARD
Moderator
Moderator
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Re: Fixed it

Postby WiZARD » Wed Jun 11, 2003 11:17 pm

brownie124 wrote:It had something to do with the variable name wincount. I am not sure what. I have no explanation really. All I know is that I changed the name and it worked fine.

Is wincount some kind of internal variable to PHP?

- Michael

i'm try to find variable name wincount.... nothing find :?

brownie124
New php-forum User
New php-forum User
Posts: 23
Joined: Thu Feb 13, 2003 1:58 pm
Location: Peterborough, NH

Postby brownie124 » Thu Jun 12, 2003 3:31 am

Hmmm, that is very odd. I wonder what it was. Could there possibly have been 2 cookie variables with the name wincount? At one time wincount was set to 0. Maybe when it was created again with the new value a duplicate was created or the value was cached someplace.

Thanks,
- Michael

User avatar
WiZARD
Moderator
Moderator
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Postby WiZARD » Thu Jun 12, 2003 11:54 pm

no.....
no possibility what one variable ave 2 value in one time....
check yore setting....


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 1 guest

cron