How to check a particular user has already logged-in to the system, by using...

Hasra

New member
...PHP SESSIONS? How to check a particular user has already logged-in to the system, by using PHP SESSIONS???

For example USER tris to access "private.html" and PHP should check whether he is already logged-in to the system using SESSIONS. If he is so then send him to "private.html" OTHERWISE REDIRECT him to loggin page.

After successful login he should be AUTOMATICALL REDIRECTED to requested page.


Please give me some Sample coding for this stuff. I'll really thankful to you.

Thank you.
 
Well, you need private.php not html.
When a user logs in, set the session vairables.
To check to make sure a user is logged in, use this script:
(considering your session variable is 'aname'):
<?
if(isset($_SESSION['aname]]))
{
//Display private content
}else{
echo "<meta http-equiv="Refresh" content='0;url='http://yoursite.com/logi...
?>
 
Back
Top