Jump to content

[SOLVED] PHP Session question..


cowboysdude

Recommended Posts

I put this in my index.php:

 

session_start();

// If they don't visit index.php this variable won't be set.

$_SESSION['has_session'] = true;

 

to set the session...

 

Then in a php file I didn't want to allow direct access without going through index.php I used this:

 

session_start();

// Check if the variable has been set.

if(!isset($_SESSION['has_session']))

{

  // It hasn't, they must go to index.php.

  header('Location: http://' . getenv('HTTP_HOST') . '/', true, 302);

  exit();

}

 

 

 

However now I get this error:

 

The browser has stopped trying to retrieve the requested item. The site is redirecting the request in a way that will never complete.

 

Now I believe the first part is setting the session and the index.php should load no matter what... however it won't load now...

 

 

Link to comment
https://forums.phpfreaks.com/topic/116719-solved-php-session-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.