• Hi

    I know that WordPress now prefers if developers don’t use native PHP session variables, but is there a built-in alternative that can be used? I can’t find anything about such a system.

    I’m happy to make my own system that uses the database and cookies to emulate sessions but if WordPress has a ready made system in place I’ll use that.

    Thanks for any info

Viewing 2 replies - 1 through 2 (of 2 total)
  • I know that WordPress now prefers if developers don’t use native PHP session variables

    Remove the word “now”, since it’s been forever. WP doesn’t use sessions, but plugins can. However, sessions are not consistently part of PHP on every server, and using them is tricky for the start and stop.
    I used them in a little-known plugin, but I never tested with another plugin also using them.
    You could look at what the shopping cart plugins use, which is probably cookies and transients, like you said.

    Thread Starter jaylj

    (@jaylj)

    Thanks, yes I meant plugins using sessions. WooCommerce is fine and I’ve recently converted a plugin to use cart item data which persists so I’ll look into their code and see how they do it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Alternative to native PHP session variables’ is closed to new replies.