user3147383
user3147383

Reputation: 13

Username stored in session changes when $username is used

Script 1 sends a username and password as POST to be inserted into a database (separate from the login system itself, instead used in an external program). Script 2 then does this:

$username = escape($_POST["username"]);
$password = escape($_POST["password"]);

However, that changes the $_SESSION["username"] to whatever username you enter in the text field on script 1. I worked around it simply by changing $username to $un, but was wondering why this happened so that I can prevent it later.

Upvotes: 1

Views: 49

Answers (1)

jeroen
jeroen

Reputation: 91734

Hard to tell without seeing more code, but do you have register_globals set to on by any chance?

That is definitely not recommended and removed from php 5.4+ but it could cause your problem. You should set it to off in your php.ini file.

Upvotes: 1

Related Questions