Jump to content

muze

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

muze's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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.
  2. Actually I am able to accomplish what I want now with MUCH simpler code. I just set a session variable on a page and reference it later to put it very simply. Anyways it's working as I intended so I'm out.
  3. What's not possible? The variable is passed onto other PHP pages using a session. I just need to check for the variable (which choice chosen) in subsequent pages and I'm trying to figure out the best way to do that.
  4. I'm trying to code the following situation, where there is a sort of choose your own adventure game for the user. I want some of the choices (designated as links into series of pages) to have variables attached to be called later (like if the "story" returns to a common page). I don't want to use a database or a form. I'm hoping I can do this with an array. I am able to successfully pass variables using $_SESSION. Here's the (bad) code I'm working on: <? $choice[one]="<p><a href='page1.php'>Do this</a></p>"; $choice[two]="<p><a href='page2.php'>Do that</a></p>"; foreach ($choice as $value) { echo $value; $_SESSION['value']=$value; //probably not necessary or useful but I need to somehow pass these values to the next page to check for them. } $_SESSION['choice']=$choice; ?> I have <? session_start(); ?> at the tops of the pages Then on page1.php I have if ($_SESSION['choice'] = "one") { echo "one;} else{ echo "two";} ?> So I'm sure it's a mess. If anyone can help, please respond.
×
×
  • 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.