WordPress $_SESSION not working even after adding add_action(‘init, ‘…’,1)

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

Read More

My wordpress version is: 3.5.2

My theme is: twentyeleven

Related posts

Leave a Reply

2 comments

  1. See this answer for a discussion of using $_SESSION with WordPress. In short, WordPress removes session variables if register_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.