Ensuring WordPress Session Start

Add this code to functions.php to guarantee that WordPress sessions start and end correctly.

add_action('init', 'myStartSession', 1);
add_action('wp_logout', 'myEndSession');
add_action('wp_login', 'myEndSession');

function myStartSession() {
if(!session_id()) {
session_start();
}
}

function myEndSession() {
session_destroy ();
}

Get a Free QuoteToo hard basket? Call us! ×
  • Your details
  • Project details
  • More details