We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Set PHP session on one page and access on different page

How Do I?

deswork's avatar
deswork
93 posts
7 years ago
deswork's avatar deswork

Hi,

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: domain.com/henry/entry/'.$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.

Thanks

Wayne.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.