I have found a bunch of articles talking about using sessions.
From what I have been able to find the best way is to add an init action.
I have been following this article
http://devondev.com/2012/02/03/using-the-php-session-in-wordpress/
But I must be missing something. every time I call the page with my plugin there is no session id.
Am I missing something?
thanks for any help
add_action('init', 'my_GB_StartSession', 1);
add_action('wp_logout', 'my_GB_myEndSession');
add_action('wp_login', 'my_GB_myEndSession');
if (!function_exists('my_GB_StartSession')) {
function my_GB_StartSession() {
if(!session_id()) {
errorLog("session startingn");
session_start();
}
}
}
function UnitNet_GB_myEndSession() {
session_destroy ();
}
try this and add to your theme’s function.php :
Now the session is yours to use as you wish in your code:
Or add this to wp-config.php before the wp-settings (e.g top of the wp-config.php)