Hi,

I'm running into a strange issue on my iPage hosted version of my website. When logging into my system, $_SESSION["id"] contains the User ID of the logged in user. Somewhere else on my site I am doing something like this to retrieve the ID of a page:

    if (isset($_GET["id"])) {
        $id = $_GET["id"];

        // Do something with the $id.
    }

However, this actually seems to change the value of $_SESSION["id"]. I tried doing the following to confirm this:

    if (isset($_GET["id"])) {
        echo $_SESSION["id"];
        $id = $_GET["id"];
        echo $_SESSION["id"];
    }

This doesn't happen when running my website on my local LAMP environment. Can anyone tell me why this is happening and how to remedy it?

Thank,
Jonathon

Might be that your webhost has register_globals enabled. Register_globals is deprecated since PHP 5.3, so if this is the case, your webhost is running an older PHP version. I guess you can see if register_globals is turned on or off by using phpinfo(), but I'm not sure.

How come you are using 2 echo commands?

Thanks for the suggestion. I've tried turning register_globals off through .htaccess but it causes me to get a 500 error. I've tried to reproduce the problem at home on my WAMP server but I am unable to reproduce it regardless of the register_globals setting. Any more ideas?

Thanks for your suggestion Minitauros. I've had my web host turn off register_globals for my site and it seems to have done the trick. I wondered why I was unable to reproduce the problem at home on my WAMP server but I've just noticed it's running PHP 5.4 in which register_globals was removed.

Thanks again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.