-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathretrieve_user_session_data.inc.php
More file actions
49 lines (40 loc) · 961 Bytes
/
retrieve_user_session_data.inc.php
File metadata and controls
49 lines (40 loc) · 961 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
39
40
41
42
43
44
45
46
47
48
49
<?php
try
{
//Connect to data base
$pdo = new PDO(DBCONNSTRING, DBUSER, DBPASS);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$queryString = "SELECT * FROM session WHERE SessionKey = '" . $_COOKIE['PHPSESSID'] . "'";
$result = $pdo->query($queryString)->fetch();
//Figure out what the user has selected to purchase if we were able to retreive from the data base
if(isset($result['SessionKey']))
{
$GLOBALS['g_ProductsInCart'] = array();
if($result['ProBook'])
{
array_push($GLOBALS['g_ProductsInCart'], '1');
}
if($result['ProWatch'])
{
array_push($GLOBALS['g_ProductsInCart'], '2');
}
if($result['ProPhone'])
{
array_push($GLOBALS['g_ProductsInCart'], '3');
}
if($result['ProMonitor'])
{
array_push($GLOBALS['g_ProductsInCart'], '4');
}
}
else
{
$GLOBALS['g_ProductsInCart'] = null;
}
$pdo = null;
}
catch (PDOException $e)
{
die();
}
?>