WordPress and PHP. Sessions and cookies.

This is more of a reminder to myself, than anything else.

  • WordPress does not use sessions as of now. They do everything via cookies.
  • Before using $_SESSION variable in PHP, one should have session_start() done. Read more about PHP sessions. In WordPress, the best place to have this is at the top of the header.php.
  • Another page load is needed after setcookie() call to be able to use the $_COOKIE variable. Read more about PHP cookies.

That’s all for now. Hopefully, I’ll spend less time bumping my head over this next time.

2 thoughts on “WordPress and PHP. Sessions and cookies.”

Leave a Comment