I am trying to get data from a MySQL table and then store it in the session. I used to define each variable like:
But after re-doing my code, there has to be an easier way. First I simply tried:
Then
Probably really stupid mistake I'm making, but can someone help me out?
Code:
$_SESSION['var1'] = $table['var1']; $_SESSION['var2'] = $table['var2'];
Code:
$_SESSION = $table
Code:
foreach( $user_data as $key => $value ) { $_SESSION[$key] = $value; }
Comment