How should you hook a session_start() when authoring a plugin?
There is no regular output and hence no header sent before template_redirect on the front end. If you need sessions on the back end too, use the action wp_loaded to cover both. Example: add_action( ‘template_redirect’, function() { $status = session_status(); if ( PHP_SESSION_DISABLED === $status ) { // That’s why you cannot rely on sessions! … Read more