-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelper.php
More file actions
24 lines (21 loc) · 738 Bytes
/
helper.php
File metadata and controls
24 lines (21 loc) · 738 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
<?php
function save_sesion($conn)
{
$session = $_SESSION;
$sesionId = session_id();
$sessionQuery = $conn->prepare("Select * from sessions where session_id = ? LIMIT 1;");
$sessionQuery->execute(array($sesionId));
$savedSession = $sessionQuery->fetch();
#create session
if (empty($savedSession)) {
$query = $conn->prepare("INSERT INTO sessions SET
session_id = ?,
session_val = ?");
$insert = $query->execute(array($sesionId,json_encode($session)));
} else {
#update session
$query = $conn->prepare("UPDATE sessions SET
session_val = ? WHERE session_id = ?");
$insert = $query->execute(array(json_encode($session),$sesionId));
}
}