I’m trying to make SESSION works with WordPress but it can’t work even I added the below code to my plugin but nothing happen:
add_action('init', 'simpleSessionStart', 1);
add_action('wp_logout', 'simpleSessionDestroy');
add_action('wp_login', 'simpleSessionDestroy');
function simpleSessionStart() {
if(!session_id())session_start();
}
function simpleSessionDestroy() {
session_destroy ();
}
How can I make $_SESSION passing date from one page to another in my wordpress site
My wordpress version is: 3.5.2
My theme is: twentyeleven
Place this code in your functions.php file
See this answer for a discussion of using
$_SESSION
with WordPress. In short, WordPress removes session variables ifregister_globals
is defined.The comments on the question itself point to this answer on the WordPress stackexchange, which discusses a plugin that may help you.