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
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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.