auth.php
<?php
session_start();
if(!isset($_SESSION["usern"])){
header("Location: login.php");
exit(); }
?>
Index.php
ko hind na ako maka pasok sa indexBaka di ka naman nag set ng session variable sa previous page?eto po yungauth.php
nilgay ko sa `Code:<?php session_start(); if(!isset($_SESSION["usern"])){ header("Location: login.php"); exit(); } ?>
Index.php
ko hind na ako maka pasok sa index
lahat puba nang page need nang authentication?Baka di ka naman nag set ng session variable sa previous page?
Lahat ng page that needs proper auth before access must check if the user is logged in or not. That's when you need to access session variables. Session variable must be set after successful login so that you can check on every page if authentication is made before page access.lahat puba nang page need nang authentication?
Nakapag login kana ?eto po yungauth.php
nilgay ko sa `Code:<?php session_start(); if(!isset($_SESSION["usern"])){ header("Location: login.php"); exit(); } ?>
Index.php
ko hind na ako maka pasok sa index
Napagana mo na ba yung login ? Itry mo i echo yung $_SESSION["usern"] kung gumagana na yung session mo.
$_SESSION["usern"] = $usern;