currently I'm doing code for login system. Login system will have remember me function(it will remember You for next 30 days). If user select yes for remember me function, server will create cookie and start session. If user desn't select yes for remember function, server will start only session user. Now I came to part when logged user trys to open page for login(prijava.php file). I put this code into jQuery file
$.ajax({
type: "POST",
url: "_hsync_scripts/_hsync_prijavljen.php",
success: function(response)
{
if(Number(response) == 1) window.location.href = "index.php";
}
});
It will run on every page load. File _hsync_prijavljen.php contains next code
<?php
if(isset($_COOKIE['_hsync_prijavljen'])) echo '1';
else if(isset($_SESSION['_hsync_prijavljen'])) echo '1'; // MAYBE PROBLEM IS HERE?
else echo '0';
?>
And login code
session_start();
if($_hsync_zapamti == 1) setcookie("_hsync_prijavljen", $_hsync_id, time() + 2592000, "/");
$_SESSION['_hsync_prijavljen'] = $_hsync_id; // MAYBE PROBLEM IS HERE?
echo '0';
If logged user trys to open login page, he will be redirect to index.php - that part Works. Part that doesn't work is next - if I log in without remember me function, and after that I type(in URL bar) link to login page, server won't redirect me to index.php. Why? This is frist time I worked with PHP sessions, maybe I don't understand the point of PHP sessions? I didn't closed tab, so seesion still must be active? Or not? Thanks!