rgraham45 Posted May 18, 2007 Share Posted May 18, 2007 I have tried to understand and read tutorials about accessing the session variables and I can't figure this out. Here is the code session_start(); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', FALSE); header('Pragma: no-cache'); $user_id = $_SESSION['is_admin']; print "<p>session var: ";print $user_id;print "<p>session var: <p>"; print_r($_SESSION); here is the result: session var: session var: Array ( [sESSION] => Array ( [user_id] => 8 [customer_id] => [is_admin] => 1 [first_name] => John [last_name] => Poppe [allow_customize] => 0 ) [enrollment_customer_id] => 9 [enrollment_user_id] => 116 ) $_SESSION['is_admin'] contains a value of 1 when I display the $_SESSION array, but when I try to get the value from the session variable I get nothing I am missing something here, any ideas, thanks Link to comment https://forums.phpfreaks.com/topic/51997-solved-_session-variable/ Share on other sites More sharing options...
clown[NOR] Posted May 18, 2007 Share Posted May 18, 2007 try this and see if that fixes your problem echo " <p>session var: $user_id </p> <p>session var: </p> "; Link to comment https://forums.phpfreaks.com/topic/51997-solved-_session-variable/#findComment-256322 Share on other sites More sharing options...
Orio Posted May 18, 2007 Share Posted May 18, 2007 It seems that $_SESSION['SESSION']['is_admin'] holds the value you need. Orio. Link to comment https://forums.phpfreaks.com/topic/51997-solved-_session-variable/#findComment-256324 Share on other sites More sharing options...
clown[NOR] Posted May 18, 2007 Share Posted May 18, 2007 oops... my bad... didnt se the [sESSION] array.... Link to comment https://forums.phpfreaks.com/topic/51997-solved-_session-variable/#findComment-256325 Share on other sites More sharing options...
sKunKbad Posted May 18, 2007 Share Posted May 18, 2007 <?php session_start(); if (!isset($user_id)){ $_SESSION['is_admin']='rgraham45'; // you gotta actually declare something $user_id = $_SESSION['is_admin']; } else { $user_id = 'somePreviouslySetValue'; } print ("The current value of the session variable is {$_SESSION['is_admin']}<br />"); print ("See for yourself:<br />"); print_r($_SESSION['is_admin']); ?> Link to comment https://forums.phpfreaks.com/topic/51997-solved-_session-variable/#findComment-256389 Share on other sites More sharing options...
clown[NOR] Posted May 18, 2007 Share Posted May 18, 2007 he has declared something... look at his array under [is_admin]... if returns 1 Link to comment https://forums.phpfreaks.com/topic/51997-solved-_session-variable/#findComment-256409 Share on other sites More sharing options...
sKunKbad Posted May 18, 2007 Share Posted May 18, 2007 try this then: print "<p>session var: ";print ($_SESSION['is_admin']);print "<p>session var: <p>"; Link to comment https://forums.phpfreaks.com/topic/51997-solved-_session-variable/#findComment-256649 Share on other sites More sharing options...
rgraham45 Posted May 18, 2007 Author Share Posted May 18, 2007 Thanks all, for you help, it is now resolved, I have been looking at it for two days Link to comment https://forums.phpfreaks.com/topic/51997-solved-_session-variable/#findComment-256652 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.