WordPress does not, by default, allow regular php sessions to be used. You can enable them, though.
The easiest way I’ve found is to add in your config file, before the call to wp-setting:
1 2 | if (!session_id()) session_start(); |
And then add this to your functions to make sure the session starts / ends correctly:
1 2 3 4 5 6 7 8 9 10 11 12 13 | add_action('init', 'myStartSession', 1); add_action('wp_logout', 'myEndSession'); add_action('wp_login', 'myEndSession'); function myStartSession() { if(!session_id()) { session_start(); } } function myEndSession() { session_destroy (); } |
Courtesy of http://silvermapleweb.com/using-the-php-session-in-wordpress/