By default you cannot create your $_SESSION in WordPress/Woocommerce.
The information in $_SESSION remain in only those files on which it is created.
You cant access $_SESSION on other file.
So, for creating your own session variable you need to install
WP Session Manager plugin.To download you can visit
http://wordpress.org/plugins/wp-session-manager/
And to use the $_SESSION you need to first create session object.
To create object use below line.
$wp_session = WP_Session::get_instance();
and to set value use
$wp_session['session_name']=array('one'=>'1','two'=>'2');
or
$wp_session['session_name']="Your value";
Note: You have to first create session object on every file where you wish to use $wp_session object.
The information in $_SESSION remain in only those files on which it is created.
You cant access $_SESSION on other file.
So, for creating your own session variable you need to install
WP Session Manager plugin.To download you can visit
http://wordpress.org/plugins/wp-session-manager/
And to use the $_SESSION you need to first create session object.
To create object use below line.
$wp_session = WP_Session::get_instance();
and to set value use
$wp_session['session_name']=array('one'=>'1','two'=>'2');
or
$wp_session['session_name']="Your value";
Note: You have to first create session object on every file where you wish to use $wp_session object.
No comments:
Post a Comment