Add the following code under the top PHP opening tag of wp-config.php.
<?php if (!session_id()) { session_start(); } ...
We can now make use of the $_SESSION[] in WordPress. The reason of putting the session_start() in wp-config.php is because this configuration file will not be overwritten during a WordPress update.
Thanks Frank Verhoeven.
Done =)
Reference: Frank Verhoeven – Using Sessions in WordPress
Updated @ 2012-08-02: Please note that their maybe security issue of using the PHP session. For more information, please refer to the following link.
PHP $_SESSION variables
Why not put on functions.php of your theme?
LikeLike
if functions.php is also included at application start up, i guess it should be ok too.
LikeLike
Hello friends, this does not work, because WP is unsetting all global variables in the wp-settings.php file.
LikeLike
I tried the above approach in WordPress 2.8.6.
which version are u using?
LikeLike
hi i have tried this as wella s putting it in the functions.php, as well as adding it to the wp_unregister_globals array….but none seems to work for me .Instead they crash my website i end up getting a blank screen. Everything reverts to normal when i remove it from the config.php or functions.php
LikeLike
What wordpress version are u using?
Have you tried to add it to wp-config.php instead of config.php and functions.php?
LikeLike
http://support.wpengine.com/php-session-variables/
LikeLike
Thanks for the link. =)
LikeLike