Jump to content

session arrays


muze

Recommended Posts

I'm trying to pass variables among many pages, in an interactive choose your own adventure game.  I created the entire thing using sessions, and everything works as intended, but during high traffic there is much slowdown.  I had memcached installed and that helped the slowdown considerably but it's still slowing down the site when there is a lot of traffic.

 

I've been told using session arrays, instead of all these individual sessions, will help alleviate the server load.

 

So I don't know if that's true or not, but I'd like to get the correct syntax for using these session arrays.

 

First question - is it absolutely necessary to call the array()  ?

 

 $_SESSION['game']=array();

 

Or if this is two separate sessions -

 

    $_SESSION['stairs'] = "true";

    $_SESSION['dance'] = "true";

 

Is this two parts of one session array?

$_SESSION['game']["stairs"]="true";

$_SESSION['game']["dance"]="true";

 

And in that case, do I need to call the array()  ?

 

I'm seeing different examples of session arrays online so I'm trying to get this clarified.  Thanks. 

 

PS The purpose of the sessions is that I need them to be checked many pages later in the game in many cases.  And I can't just add all the parts of the array at once, which is why I create an empty array first, to have items added as necessary as a user progresses through the game.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.