Re: Pushing Vars into $_SESSION

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 18/04/06, Chris Grigor <chris@xxxxxxxxxxxxxx> 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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux