<?php
    session_start();
    include_once "config/_globle.php";
	include_once "api/AUTh/check_user.php";
    if ($existing_user=="false") {
        // header("location:login.php?l=". $_POST["username"]);
        header("location:https://stardigitalmm.com/555/login.php?l=". $_POST["username"]);
    } else {
		date_default_timezone_set('Asia/Rangoon'); 
        //$result =  mysql_query("INSERT INTO `user_log` VALUES ('" .  date("Y-m-d H:i:s") . "','" . $_POST["username"] .  "','LogIn','LogIn', '" . $_SERVER["REMOTE_ADDR"] . "')");
        $_SESSION['user']= $user->username;
        $_SESSION['userrole'] = $userrole;
        $_SESSION['user_rn_dm']= rand(10000, 100000);
		$_SESSION['profilepicture'] = $profilepicture;
		$_SESSION['userid'] = $userid;
        $_SESSION['code'] = $code;
        $_SESSION['city'] = $city;
        $_SESSION['start'] = time(); // taking now logged in time
        $_SESSION['expire'] = $_SESSION['start'] + ((180 * 60)*18); // ending a session in 30 minutes from the starting time

        if($userrole=="SuperAdmin" || $userrole=="Admin"){
            $_SESSION['admin_access'] = true;
            header("location:index_admin.php");
        }else{
            $_SESSION['employee_access'] = true;
            header("location:index.php");
        }
    }
?>