Sunday, October 20, 2013

Maintaining and Using Sessions in Wordpress

Hiiii, We all know the importance of maintaining sessions and session variables on our website and use the value of that variables on any page of our website once they are declared  and assigned with some value.
But what happen when you have to maintain sessions in Wordpress for some custom module.Wordpress by default doesn't maintain sessions as used in PHP and it then also you do so, that value declared to session variable will be accessible once on that page but you cannot use that value on any other pages.
To solve this problem , in this post I'll be telling you how to maintain sessions in wordpress.

Wordpress Sessions


Steps to maintain Sessions in Wordpress  :

1. Firstly install WP Session Manager  plugin in wordpress.

2. After installing this plugin , just write as shown below to start a session and declare a value to some session variable:
   $wp_session = WP_Session::get_instance();                // Starting a Session
   $wp_session['Session variable Name']= "Your value";     // like $wp_session['my_sess']="MyCodeStock";
  
Now you can use you session variable on any page in you wordpress just like Session variables used in PHP website.

NOTE : WP Session Manager allows same functionality of Sessions as in Core PHP and with this plugin you can use session variables in wordpress same as Core PHP.

Hope you like this post……..Please Comment…………!!!!!!!!!


Tags:

0 Responses to “Maintaining and Using Sessions in Wordpress”

Post a Comment

© 2013 MyCodeStock. All rights reserved.
Designed by SpicyTricks