I Can’t Access a Cookie I Set In PHP

A lot of people (including me) experience problem accessing a cookie immediately after setting it. The thing is that you can’t access a cookie inside the same request that is used to set it. Meaning that if your script sets a cookie using setcookie(), you have to reload the page using header(“Location: anotherpage.php”) to process and read the cookie inside the script called anotherpage.php.

[ad name=”In Post (LU)”]

I hope it’s clear now. If not, don’t hesitate to comment.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.