Re: Pushing Vars into $_SESSION
| From: | Paul Waring | Date: | Tue, 18 Apr 2006 15:34:25 +0000 |
| Subject: | Re: Pushing Vars into $_SESSION | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-234186@lists.php.net to get a copy of this message | ||
On 18/04/06, Chris Grigor <chris@youandme.co.za> wrote:
> Was wondering if there is an easier way to get returned variables into
> the $_SESSION rather than going through each one??
First of all, why are you using mysql_fetch_object and then passing in
MYSQL_ASSOC? You should be using $line = mysql_fetch_array($result)
instead. If you get the row data as an associative array, you can then
simply do:
foreach ( $line as $key => $value )
{
$_SESSION[$key] = $value;
}
That way, whatever columns you select from the database will
automatically be loaded into session variables, so if you change the
SQL, you'll also change the sessions. I think this is what you're
asking for, apologies if I'm misinterpreted the question.
Paul
--
Data Circle
http://datacircle.org