-
Notifications
You must be signed in to change notification settings - Fork 0
/
sessions.php
executable file
·52 lines (45 loc) · 1.37 KB
/
sessions.php
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
include_once 'database.php';
session_start();
$database = new Database();
$db = $database->getConnection();
//checking user for sessions
$user_check = $_SESSION['login_user'];
//echo "echoed from sessions.php<br>";
//echo $user_check;// to check the google_id of user
//checking in database username
//THIS NEEDS TO BE UPDATED
//WILL BE DONE USING API
//$ses_sql = mysqli_query($db,"SELECT google_id from profile where google_id = '$user_check'");
/*
while($row = mysqli_fetch_assoc($ses_sql))
{
$session_usr=$row['google_id'];
//echo $session; //to check the username
}
*/
$post = [
'live_token' => $read_live_token,
'req_type' => $read_req_type,
'google_id' => $user_check,
];
$ch = curl_init($base_url."/api/users/check_session.php");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
// execute!
$response = curl_exec($ch);
// close the connection, release resources used
curl_close($ch);
// do anything you want with your response
$records = json_decode($response);
$tmp = $records->{'message'};
//Temporary solution, can backfire under certain conditions
//$session_usr = $user_check;
if($tmp) {
$session_usr = $user_check;
}
else {
header("Location:index.php");
}
?>