-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathajax.php
42 lines (34 loc) · 946 Bytes
/
ajax.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
<?php
$cookie_name = "kombatsave";
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$data = json_decode(file_get_contents('php://input'), true);
if(!isset($_COOKIE[$cookie_name])) {
$cookie_value = json_encode($data);
setcookie($cookie_name, $cookie_value, time() + (86400*30), "/");
} else {
$currentcookie = $_COOKIE[$cookie_name];
$cookie_new_value = json_encode($data);
setcookie($cookie_name, $cookie_new_value, time() + (86400*30), "/");
$cookie = $_COOKIE[$cookie_name];
$cookie = stripslashes($cookie);
$savedCardArray = json_decode($cookie, true);
echo "Data saved";
}
} elseif ($_SERVER['REQUEST_METHOD'] === 'GET'){
$q = $_REQUEST['q'];
if($q == "getData"){
if(!isset($_COOKIE[$cookie_name])){
echo "false";
} else {
$cookie = $_COOKIE[$cookie_name];
echo $cookie;
}
} elseif($q == "check"){
if(!isset($_COOKIE[$cookie_name])){
echo "false";
} else {
echo "true";
}
}
}
?>