How to check if logged in?

Status
Not open for further replies.

TheJoshy

PlusHost.org -> GOGOGO
Jul 4, 2010
287
56
I want to know a code to check if the user is logged in when they view a page, if not - redirect them to index?

I could have the code on 1 page then php include it on to every page.

Thanks. <3
 

Kaz

BooYah
Staff member
Nov 16, 2010
3,064
1,025
you could use something like this
PHP:
/**
* Checks if the user is logged in
*/
 
if($_SESSION['user_id'] == NULL) {
    $_SESSION['login_error'] = "You need to login to view this page!";
    die(header('Location: '.PATH.'/'));
}
 

Sledmore

Chaturbate Livestreamer
Staff member
FindRetros Moderator
Jul 24, 2010
5,195
3,906
If you read through the files, this is already coded, in a switch case, just add the page name.
 
Status
Not open for further replies.

Users who are viewing this thread

Top