Im trying to rebuild a login on my website, Ive inherited the website but the login is currently built with ajax and take forever to login.
Ive written the following that allows users to login...
<form name="form1" method="post" action="checklogin.php">
<input name="myusername" type="text" id="myusername">
<input name="mypassword" type="text" id="mypassword">
<input type="submit" name="Submit" value="Login">
</form>
If login is a success the user is redirected...
header("location:earn-credits.php");
My probelm is though, when the user is sent to the "Earn-credits" page theres a check to see user is login which, if they aren't sends the user back to the homepage...
if(!$usersClass->checkLoggedIn()) {
header("Location: /index.php");
}
Now I know my users are logging in with the above form as theyre being redirected and im receiving no error messages.
Im new to PHP and AJAX so what im asking is why is this? Do I need to set a cookie?
Below is my class to check the user is logged in...
/**
* check if user is logged in
*/
public function checkLoggedIn()
{
if(isset($_SESSION['loggedIn']))
{
if(isset($_SESSION['loggedIn']['id']) &&
isset($_SESSION['loggedIn']['username']) &&
isset($_SESSION['loggedIn']['password']) &&
isset($_SESSION['loggedIn']['credits']) &&
isset($_SESSION['loggedIn']['active'])) {
return true;
}
}
return false;
}