Jump to content

Session ID showing up in URL


Marfisa

Recommended Posts

I made a silly little game using sessions and it's supposed to be using cookies, but in both Firefox (1.0.4) and IE (6.0.26), no matter which is the first link you click on (of the pets to trade with, not the sidebar), it will show the session id in the url when I thought it was supposed to be using cookies. You have to go back one page to get it to work again. Also, in IE, it randomly (to me anyway) shows blank pages when you click on the names. I'm sorry if this has already been answered somewhere, but I've had a really hard time trying to look up this problem since I don't know what it might be called.

Oh, my domain is set for PHP4, and I don't have access to the server. Although I do have the option of switching it to PHP5. It's on PHP4 because changing it to 5 broke some other code on the site, although that's an issue for another post sometime.

The first three lines of code above the session start are various fixes I've been trying, I don't know if they're necessary at all.

To see this problem in action, here is the link-
http://academy.neo-romance.net/games_trade2.php

Here is the code, it's just a snippet, but all along the same vein. Also, I haven't quite finished coding the whole thing yet, so I haven't closed the session anywhere. I figured it was ok for it to end with the browser closing for my testing purposes.

[code]
    <?php
    header('P3P: CP="CAO PSA OUR"');
    header("Cache-control: private");
    ini_set(session.use_only_cookies,1);
    session_start();

    include('top.php');
    include('reward.php');

    if (!$_SERVER['QUERY_STRING'])  {

    if (!session_is_registered("active"))
      {
      session_register("active");
      $active=1;
      session_register("candy");
      $candy="shrimp";
      }

    ?>
    <h2>trick or trade!</h2>
    <?

    echo "<p>You have a " . $_SESSION['candy'] . "!</p>\n";

    ?>
    <P>
    Who would you like to try trading with next?
    </P>

    <P align="center">
    <a href="games_trade2.php?fatty">Mr. Fattykins</a> |
    <a href="games_trade2.php?chunky">Chunkypuff</a> |
    <a href="games_trade2.php?mishe">Mishe Mishe</a> |
    <a href="games_trade2.php?itty">Ittypuff</a> |
    <a href="games_trade2.php?bitty">Bittypuff</a> |
    <a href="games_trade2.php?sydney">Sydney</a> |
    <a href="games_trade2.php?trouble">Trouble</a>
    </P>
    <?

    } elseif ($_SERVER['QUERY_STRING'] == "fatty") {

    ?>
    <h2>trick or trade!</h2>
    <?

    echo "<p>You have a " . $_SESSION['candy'] . "!</p>\n";

    if ($_SESSION['candy']=="shrimp")
      {
      echo "<p>Mr. Fattykins trades your " . $_SESSION['candy'] . " for a tuna.</p>\n";
      $_SESSION['candy']="tuna";
      }
    elseif ($_SESSION['candy']=="chicken leg")
      {
      echo "<p>Mr. Fattykins trades your " . $_SESSION['candy'] . " for a coral.</p>\n";
      $_SESSION['candy']="coral";
      }
    elseif ($_SESSION['candy']=="scallop")
      {
      echo "<p>Mr. Fattykins trades your " . $_SESSION['candy'] . " for a snail.</p>\n";
      $_SESSION['candy']="snail";
      }
    elseif ($_SESSION['candy']=="shell")
      {
      echo "<p>Mr. Fattykins trades your " . $_SESSION['candy'] . " for a prize.</p>\n";
      $_SESSION['candy']="prize";
      }
    else
      {
      echo "<p>Mr. Fattykins is not interested in your "  . $_SESSION['candy'] . ".</p>\n";
      }

    ?>
    <P>
    Who would you like to try trading with next?
    </P>

    <P align="center">
    <a href="games_trade2.php?fatty">Mr. Fattykins</a> |
    <a href="games_trade2.php?chunky">Chunkypuff</a> |
    <a href="games_trade2.php?mishe">Mishe Mishe</a> |
    <a href="games_trade2.php?itty">Ittypuff</a> |
    <a href="games_trade2.php?bitty">Bittypuff</a> |
    <a href="games_trade2.php?sydney">Sydney</a> |
    <a href="games_trade2.php?trouble">Trouble</a>
    </P>
    <?

    }

    include('bottom.php');
    ?>
[/code]
Link to comment
Share on other sites

I managed to fix the problem with session ID showing up in the URL by adding this line to the top of the code, above the session start.

[code]
ini_set('url_rewriter.tags', '');
[/code]

But I'm still getting errors with both Firefox and IE. Firefox sometimes comes up with a blank page when you first click a link and IE is still randomly shows blank pages as you click on the links.
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.