-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
29 lines (22 loc) · 697 Bytes
/
Copy pathindex.php
File metadata and controls
29 lines (22 loc) · 697 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
<?php
// REQUIREMENTS
use PHPcookie\CookieSession;
require_once './cookie.php';
// MAIN PROGRAMM
const COOKIE_NAME = "cookie_name";
const DEFAULT_COOKIE_TIME = 60*60*24*365; # one year duration
$cookie_value = "give a value to your cookie";
// INSTANTIATION
$cookie = new CookieSession(COOKIE_NAME, $cookie_value, time() + DEFAULT_COOKIE_TIME);
// LAUNCH
$answer = $cookie->start();
// you must redirect to another page for the cookie to exist
#header("Location: ./");
// UPDATE
$answer = $cookie->update(time() + 60 * 60);
// GET VALUE
$cookie_value = $cookie->getValue();
// DESTRUCTION
$answer = $cookie->stop();
// redirection to the login page or somethinglike
#header("Location: ./");