I have a few session variables that I define when the user logs into the system. When they click "submit" it goes to "check-login.php" where it checks for a few specified criteria (whether user is admin or not and if the user exists).
I am connecting to a 3rd party system where I am checking for login credentials. Basically, the user puts in their email as the username and it calls the 3rd party api to see if the email exists. If it does, it checks password and sets $_SESSION['myusername'] to the email and $_SESSION['mypassword'] to the password.
That all works just fine. Where I run into issues is when it redirects to "index.php", I have a redirect setup just in case someone tries to access "index.php" without logging in. Well, for some reason no session variables are carried over to "index.php".
check-login.php
<?php include('../includes/session.php');
// Register $myusername, $mypassword and redirect to appropriate location
$_SESSION['myusername'] = $myusername;
$_SESSION['mypassword'] = $mypassword;
header('Location: index.php');
session.php has "session_start();" and some miscellaneous functions
index.php (just the header)
<?php include("../includes/session.php"); ?>
<?php include("../includes/functions.php"); ?>
<?php include("../public/login-success.php"); ?>
login-success is where the redirect happens
// Check if session is not registered, redirect back to main page
if (!isset($_SESSION['myusername'])) {
$_SESSION['message'] = 'You need to be logged in to do that';
redirect_to('../public/login.php');
}
$_SESSION['message'] carries over back to login.php and displays just fine so something is happening with $_SESSION['myusername'] to where it's not carrying over from check-login.php
In "login-success.php" I used print_r on SESSION and it didn't return anything. Moving the print_r to the 2nd line of "index.php" doesn't return anything either.