Using a PHP cookie in javascript?

T

tomb

Is it possible to use a php cookie in javascript? The one I am setting
in my php code is domain and path specific.

TIA

Tom
 
S

Sudrien

Is it possible to use a php cookie in javascript? The one I am setting
in my php code is domain and path specific.

TIA

Tom

Cookies are generic objects - there is no php-specific cookie. Also,
they are domain specific by default - I don't see why you would need
to set a specic path, but you know your situation.

Cookies are simply name/value pairs that are sent with every page
request. That is *every* request to the specified path and domain, so
you want to keep cookies small as possible.

Compare the following documentation:

http://us.php.net/setcookie
http://www.quirksmode.org/js/cookies.html

As you can see, there is no way to specify domain or path while
reading cookies - only when writing them. The browser decides what
cookie information is relevent depinding on the current URL.

[generic plug for firebug, which also allows you to look at http
headers]


-Sud
 
T

tomb

Sudrien said:
Is it possible to use a php cookie in javascript? The one I am setting
in my php code is domain and path specific.

TIA

Tom

Cookies are generic objects - there is no php-specific cookie. Also,
they are domain specific by default - I don't see why you would need
to set a specic path, but you know your situation.

Cookies are simply name/value pairs that are sent with every page
request. That is *every* request to the specified path and domain, so
you want to keep cookies small as possible.

Compare the following documentation:

http://us.php.net/setcookie
http://www.quirksmode.org/js/cookies.html

As you can see, there is no way to specify domain or path while
reading cookies - only when writing them. The browser decides what
cookie information is relevent depinding on the current URL.

[generic plug for firebug, which also allows you to look at http
headers]


-Sud

That was the best explanation on javascript cookies I've seen so far.
Thanks so much! I am now very comforted by this information that my
application will be able to do what I need it to do.

T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,416
Latest member
LionelQ387

Latest Threads

Top