Learning more about sessions I've gathered that a session_start()
should come directly after <?php
per Where exactly do I put a SESSION_START? and I wanted to play around and create a plugin that would add a session_start()
to header.php
after it's <?php
but after searching I've been inclusive with trying to figure out the appropriate procedure to do this.
I did search for session but I've seen a variety of Q&As that mostly seem to use:
init
: Session is not startingwp_head
: Hook into wp_head(); in a pluginwp_loaded
: Getting headers already sent error from plugin
So when authoring a plugin that relies on session to be added to header.php what is the appropriate hook for adding session_start()
?
if ( !session_id() ) { session_start(); }
so I don't think it's really important but it should definitely be checked before you need to use the $_SESSION. But I'm curious if someone has a better explanation