Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read a PHP cookie from JavaScript

I have a PHP script which sets a cookie called user. I need to be able to read the value from this cookie in javascript.

Can this even be done.

Thanks for any help you can provide.

like image 535
Boardy Avatar asked Nov 03 '11 20:11

Boardy


1 Answers

There's no such thing as a "PHP cookie" or a "javascript cookie". There's just cookies, which you can access from PHP and Javascript. In JS, you'd use document.cookie to access the raw cookie data. There's plenty of libraries which give you finer-grained access as well,

like image 124
Marc B Avatar answered Sep 20 '22 17:09

Marc B