Login Script

I have 2 PHP scripts which use seperate MYSQL databases to manage users.  I know very little about PHP and MYSQL, but I would like to find some code which will allow a user logged into one of the scripts to be able to go to the other script without having to login (user's logins are the same for both scripts and databases).  Is there any easy way to do this or is this something I have to have my original programmers do? Thanks for your help!
Who is Participating?
glcumminsConnect With a Mentor Commented:
In your login code, after a successful login you should set a session variable to denote a successful login. For example,


// On successful login
$_SESSION['username'] = $username;

Then, in each of your scripts, check for the existing of the 'username' variable in the session. If it exists, the user is logged in. If not, redirect the user to the login script:


if (isset($_SESSION['username']) && !empty($_SESSION['username']))
   // Show the script
   // User is not logged in, so send him to the login page
   header("Location: login.php");
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.