Set PHP session on one page and access on different page

October 10, 2017 7:39am

Subscribe [1]
  • #1 / Oct 10, 2017 7:39am


    81 posts


    I’ve enabled PHP in a number of templates in a template group. I want to restrict access to certain templates based on a session been set. When a visitor submits a form it creates a session and redirect to a competition entry page, see code below.

    $_SESSION["entered_code"] = "submitted";
    header( 'Location:'.$code ) ;

    On the entry page I want ot check if the session has been set, if not redirect the visitor back to the index page.

    if( ! isset($_SESSION["entered_code"])){
     header( 'Location: domain/henry' ) ;

    The problem is the session id on the entry page is different to the id on the page where I want to check the session, so the session is not available.

    Is there a way to set and acces PHP sessions across different pages.



.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases