Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

My wordpress version is: 3.5.2

My theme is: twentyeleven

like image 591
usama sulaiman Avatar asked Dec 02 '22 18:12

usama sulaiman


1 Answers

Place this code in your functions.php file

function sess_start() {
    if (!session_id())
    session_start();
}
add_action('init','sess_start');
like image 169
Muhammad Rehman Avatar answered Dec 10 '22 20:12

Muhammad Rehman