Hello,
I have a question in my mind whene ever we create a login page why we store the variables in $_SESSION why is this done so my senior developer told me when recently i was creating cms in which I created 1 admin and 1 user page he sent me a script to place i added the script but didn't understood about the the concept what did he actually did so and why he placed the ulogin and user tyoe in session variable well it cannot be done without setting up in superglobal variable ??
Here is the script
<?php
session_start();
include_once("include/config.php");
$login = $_POST["textfield1"];
$pwd = $_POST["textfield2"];
$recordset = mysql_query("select * from users");
while($record = mysql_fetch_array($recordset)){
if($login == $record["ulogin"] && $pwd == $record["upassword"]) {
$_SESSION["ulogin"] = $record["ulogin"];
$_SESSION["uid"] = $record["uid"];
if($record["utype"] == 1){
$_SESSION["utype"] = $record["utype"];
header("Location:admin.php?uid=".$record["uid"]);
exit;
} else {
header("Location:home.php");
exit;
}
}
}
header("Location:login.php?invalid=1");
?>
Please let me know if any one would be able to help me out or make me understand about this concept it would be really appreciated
Thank You