Reputation: 53
I have used session_start() in two templates of my wordpress site. In local server the i can able to use session variable in both the templates. But in live server i am unable to retrieve the session value. It shows blank array when i use print_r($_SESSION)
Thank You
Upvotes: 1
Views: 4693
Reputation: 3629
WordPress will allow only these Variables:-
'GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES'
wp_unregister_GLOBALS
this function will reset your SESSION
for some security reason. you can find this function in WordPress Package (File:- wp-includes/load.php
)
You can find Documents Here.
So, If you want to use SESSION
than you need to use plugin for allow SESSION
variable to use.
Hope it will help you.
Upvotes: 3
Reputation: 455
Place this code in your functions.php file
function ses_init() {
if (!session_id())
session_start();
}
add_action('init','ses_init');
Upvotes: -1