Spoofy Spoofy - 1 year ago 100
PHP Question

Get/Read Javascript cookie with PHP

I have a theoretical question..

I know that you can get/read a PHP cookie with javascript by using: document.cookie

Is there a similar way to do this in PHP?

Can PHP get/read a cookie that is created i JavaScript?
If yes, then how can you do that?

Answer Source

You can use $_COOKIE, the superglobal. Just reference it like you would any array, where $_COOKIE['key_name'] is the cookie you want to access.

See the PHP API documentation.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download