navalhawkeye
navalhawkeye

Reputation: 259

PHP Session variables; works on one computer, not on another

So I have a development computer, and a production server. On the dev computer everything works great. I copy the site to the production server and my session variables aren't working.

I am using a simple login script and register the session username after the person logs in.

session_register("myusername");

I then put in a catch for testing purposes right below that.

if(isset($_SESSION['myusername'])) {
                echo "set";
            }
            else {
                echo "not set";
            }

On the dev computer it prints out set. On the production server it prints out not yet. The interesting part, is that the exact same code works on another part of the site perfectly fine.

I'm working on an inventory system, and am using the registered login name to generate a change log so that it's possible to see who did what to a system.

Like I said, this same code works fine on another part of the system (the reason I'm not reusing it is because they are separate logins, though into the same AD database).

Is there something obvious I'm missing that would cause the same code to:

A. Works on one part of the site and not another. B. Works on the test computer in both places, and works on the development site in the original login.

Thanks

Upvotes: 0

Views: 1054

Answers (1)

Naftali
Naftali

Reputation: 146302

DO NOT use session_register, as it has been deprecated.

Try this:

session_start();
$_SESSION['myusername'] = 'something';

if(isset($_SESSION['myusername'])) {
    echo "set";
}
else {
    echo "not set";
}

Upvotes: 4

Related Questions