Page 1 of 1

Add session

Posted: Wed Nov 08, 2006 9:31 am
by acwe88
Hi there

I need to add a session to my page that Gets A value from the database and according to that value it redirects the user to a particular part of the site

any ideas anyone?

any help will be much appreciated

Thanks
Al

Posted: Wed Nov 08, 2006 9:53 am
by printf
I don't see why you need a session, do your query then do the redirect...

Code: Select all

// db connect, select here

$query = mysql_query ( "SELECT permission FROM users WHERE uid = " . $user['id'] );

$test = mysql_fetch_assoc ( $query );

switch ( $test['permission'] )
{
	case 0 :
	$page = 'login.php';
	break;
	case 1 :
	$page = 'admin.php';
	break;
	case 2 :
	$page = 'members.php';
	break;
}

header ( 'Location: http://www.site.com/' . $page );
exit ();

printf

Posted: Wed Nov 08, 2006 11:10 pm
by wyrmmage
session_start() starts a session, then you can access variables like this:

Code: Select all

<?
session_start();

$_SESSION[$variableName] = "whatever";

?>
-wyrmmage