Re: Pushing Vars into $_SESSION

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

 



Richard Lynch wrote:

On Wed, April 19, 2006 1:36 am, Chris Grigor wrote:
Richard Lynch wrote:

On Tue, April 18, 2006 10:05 am, Chris Grigor wrote:
Was wondering if there is an easier way to get returned variables
into
the $_SESSION rather than going through each one??

foreach($line as $key => $value) $_SESSION[$key] = $value;

Why do this?
Is it really going to help you to have the data stored in TWO
places?
I predict that if you really think about what you are doing, you
won't
want to do this.  There are simply too many pitfalls for this to be a

The point of me doing this is that I will be pulling menu flags from a
database on a user level.

in the db I will have menu items 1 to 20 turned on or off. When a user
logs in these flags are pulled
and depending if they are truned on or off, the menu will display.
Catch my drift??

Tell us the part about where having them copied into $_SESSION makes
your software better... :-)

Database -> Menu is a very simple and common web design.

Database -> $_SESSION -> Menu only adds an extra step, AFAICT.

Are you able to completely avoid connecting to the database on many
subsequent pages this way?  That could be Good Code.

Or are you just avoiding a single simple query that, with indexed
fields, should run in a splintered second?  That's probably Bad Code.

$_SESSION data is not free.

It's not even cheaper than MySQL data, as a general rule -- though it
might be in specific cases.

Simplify, grasshopper.
:-)

The method behind the madness here, is that I am only pulling the data once from the db throughout the whole session. This means that all the user info is available on every page they visit. I can also then identify on each page that loads if a user has signed in and a session is present. Do you think I am going about this in the wrong way? What would you suggest is a better idea???

Chris

--
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