Title: Alternative to native PHP session variables
Last modified: May 20, 2021

---

# Alternative to native PHP session variables

 *  [jaylj](https://wordpress.org/support/users/jaylj/)
 * (@jaylj)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/alternative-to-native-php-session-variables/)
 * 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)

 *  [Joy](https://wordpress.org/support/users/joyously/)
 * (@joyously)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/alternative-to-native-php-session-variables/#post-14464097)
 * > 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](https://developer.wordpress.org/apis/handbook/transients/),
   like you said.
 *  Thread Starter [jaylj](https://wordpress.org/support/users/jaylj/)
 * (@jaylj)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/alternative-to-native-php-session-variables/#post-14464129)
 * 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.

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)
 * [session variables](https://wordpress.org/support/topic-tag/session-variables/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 2 participants
 * Last reply from: [jaylj](https://wordpress.org/support/users/jaylj/)
 * Last activity: [4 years, 12 months ago](https://wordpress.org/support/topic/alternative-to-native-php-session-variables/#post-14464129)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
