Hi I'm new to angularJS and PHP,
I'm trying to maintain session between two pages and the code as follows,
Index.php
<?php
session_start();
if(!isset($_SESSION["id"])) {
$post_date = file_get_contents("php://input");
$data = json_decode($post_date,true);
$nme = $data['name'];
$passwd= $data['password'];
if (mysql_query("SELECT * FROM `admin_auth` WHERE `username` = '$nme' and `password` = '$passwd' ")) {
$_session["id"] = $nme;
echo $_session["id"];
return;
} else {
echo "invalid user";
}
}
?>
and I'm checking the session as follows
exe.php
<?php
session_start();
if(!isset($_SESSION['id'])){ //if login in session is not set
header("Location:index.php");
}
echo "SESSION set";
?>
It will always redirect me to the index page even when the session is set in index page. Index.php printing out correct value