hi all
Moderator: General Moderators
-
crazycoders
- Forum Contributor
- Posts: 260
- Joined: Tue Oct 28, 2008 7:48 am
- Location: Montreal, Qc, Canada
Re: hi all
Please move this to general coding questions, thanks...
To anwser your question, pretty simple, just use the $_SESSION array. You check if the $_SESSION array contains a value of your choice stating if the user has logged on or not. For example:
To anwser your question, pretty simple, just use the $_SESSION array. You check if the $_SESSION array contains a value of your choice stating if the user has logged on or not. For example:
Code: Select all
CheckSession.php
<?php
session_start();
if(!isset($_SESSION['userid'])){
heder('location: login.php');
exit();
}
?>
Code: Select all
login.php
Ask for user authentication in there using <form>, <input> and <submit> tagsCode: Select all
dologin.php
<?php
session_start();
/*Use the database to validate login credentials then*/
if($validlogin == true){
$_SESSION['userid'] = $userid;
header('location: firstpage.php');
exit();
}
?>