...

View Full Version : Shared/Global Session variable



logictrap
12-01-2010, 07:53 PM
Is it possible to have a session variable that is shared between different users sessions?

As an example, is it possible to declare something like this:

$todays_color='red';

User 1 Session
echo $_SHARED_SESSION['todays_color']; //outputs: red

User 2 Session
echo $_SHARED_SESSION['todays_color']; //outputs: red

Lamped
12-01-2010, 08:15 PM
I think you're overcomplicating it. Effectively the same thing can be achieved by saving data in a database or file, but use a function to read and set the value so your code doesn't bloat too much. You can link the sessions to the database entry or file by setting a session variable for each relevant user.

logictrap
12-02-2010, 06:54 PM
Thanks, I was trying to avoid that using a mysql query for that. I may use an include.

Any advice about whether using includes vs mysql queries is less taxing on server resources?

Lamped
12-02-2010, 07:56 PM
Actually, includes should be substantially faster and less server intensive overall... It's just a ***** to manage properly. Databases, for all their overhead, are gold for management.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum