I want to prevent user to access login page when its already logged in. In header page I've checked session so that user can't access any admin page without logging in. What code do I have to write in header page and session page to prevent user access login page while already logged in?
Here's my session class
public static function init(){
session_start();
}
public static function set($key, $val){
$_SESSION[$key]=$val;
}
public static function get($key){
if (isset($_SESSION[$key])) {
return $_SESSION[$key];
} else {
return false;
}
}
public static function checkSession(){
self::init();
if (self::get("login")==false) {
self::destroy();
header("Location:login.php");
}
}
public static function destroy(){
session_destroy();