Jump to content

Redirect - To home page if not logged on


mlj0102

Recommended Posts

I have an issue I am not sure how to solve.  What I want to do is to make sure authentication has already occurred .  Or that my $currentMember is set and it if is set for an IF statement to do nothing..  However it it is not set for a redirect to the home page with no echo statements or anything to that nature just a redirect. Am I even close?

 

<?php


	include( ABSOLUTE_PATH . 'class/database.class.php' );
	include( ABSOLUTE_PATH . 'class/person.class.php' );

	//Start Session
	session_start();

	$currentMember = unserialize($_SESSION['currentMember']);

	$db = new Database;
	$person = new Person($currentMember->memberid);


	if ( $auth_satus == 0 ) {
		header('Location:' . APP_ROOT . 'index.php');
		}

		exit();

	?>

             

 

Link to comment
https://forums.phpfreaks.com/topic/261871-redirect-to-home-page-if-not-logged-on/
Share on other sites

Not sure why that wouldn't work for you. A header redirect only works if nothing else has been sent to the browser yet, so the only thing I can think of is something in your include files or your class constructors that's posting to the browser before you get a chance to redirect. If that's the case though you should get a warning.

 

Is it possible it's not working because you're checking the value of $auth_satus instead of $auth_status? Also should $auth_status belong to something, ie $person->auth_status?

 

 

On a side note you're probably better off using individual session variables to track your member than a serialized object.

 

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.