Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder logictrap's Avatar
    Join Date
    Apr 2008
    Posts
    155
    Thanks
    11
    Thanked 3 Times in 3 Posts

    Shared/Global Session variable

    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

    Which came first - the chicken or the egg? The egg... [ticket closed]
    If a tree falls... does it make a sound? Yes.............. [ticket closed]

  • #2
    Super Moderator
    Join Date
    Feb 2009
    Location
    England
    Posts
    539
    Thanks
    8
    Thanked 63 Times in 54 Posts
    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.
    lamped.co.uk :: Design, Development & Hosting
    marcgray.co.uk :: Technical blog

  • #3
    Regular Coder logictrap's Avatar
    Join Date
    Apr 2008
    Posts
    155
    Thanks
    11
    Thanked 3 Times in 3 Posts
    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?

    Which came first - the chicken or the egg? The egg... [ticket closed]
    If a tree falls... does it make a sound? Yes.............. [ticket closed]

  • #4
    Super Moderator
    Join Date
    Feb 2009
    Location
    England
    Posts
    539
    Thanks
    8
    Thanked 63 Times in 54 Posts
    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.
    lamped.co.uk :: Design, Development & Hosting
    marcgray.co.uk :: Technical blog


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •