-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsessions.php
More file actions
38 lines (30 loc) · 810 Bytes
/
sessions.php
File metadata and controls
38 lines (30 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
session_start();
class SessionManager{
static function isLoggedIn(){
return isset ($_SESSION["user"]);
}
static function login($email, $pwd){
require_once("db-manager.php");
$SQL = "SELECT `id`, `name`, `email`, `password`, `type` FROM `users` WHERE `email` = '$email'";
$result = mysqli_query($cxn, $SQL);
if(@$row = mysqli_fetch_assoc($result)){
extract($row);
if($pwd == $password){
$_SESSION["user"] = $id;
$_SESSION["type"] = $type;
$_SESSION["name"] = $name;
$_SESSION["email"] = $email;
if($type !== "user"){
return "admin";
}else{
return "user";
}
}else{
return "password error";
}
}else{
return "email error";
}
}
}