This repository was archived by the owner on Apr 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
80 lines (61 loc) · 1.78 KB
/
Copy pathexample.php
File metadata and controls
80 lines (61 loc) · 1.78 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
// Load Composer.
require_once __DIR__ . '/vendor/autoload.php';
// Create helper function.
function session($keys = null)
{
return new Devfake\Rese\Session($keys, '.');
}
// Helper for example.
function pp($content)
{
echo '<pre>';
print_r($content);
echo '</pre>';
}
?>
<!doctype html>
<html>
<head>
<title>Example Site For Session Wrapper Class</title>
<style>h4 { padding: 20px 0 0 0; border-top: 1px solid gray; }</style>
</head>
<body>
<?php
// Reset sessions for new loading.
session()->destroy();
// Show empty $_SESSION:
echo '<h4>Empty session:</h4>';
pp(session()->get());
// Create new Session:
session('Stark')->set('Winter Is Coming');
// Show $_SESSION with just created key/value:
echo '<h4>Session with new value:</h4>';
pp(session()->get());
// Get a session.
echo '<h4>Get a session by key:</h4>';
echo session('Stark')->get();
// Add nested session:
session('who.knows.nothing')->set('Jon Snow');
// Show $_SESSION with just created nested key/value:
echo '<h4>Add nested session:</h4>';
pp(session()->get());
// Remove key from nested session ('nothing' will be deleted):
session('who.knows.nothing')->remove();
// or session('who.knows.nothing')->delete();
// Show $_SESSION with without 'nothing':
echo '<h4>Show session with deleted key:</h4>';
pp(session()->get());
// Check if value exists:
echo '<h4>Check if "Stark" exists:</h4>';
pp(session('Stark')->exists());
// Compare two values:
echo '<h4>Compare if value from "Stark" is "A Lannister always pays his debts"</h4>';
if(session('Stark')->is('A Lannister always pays his debts')) {
echo "yep";
} else {
echo "nope";
}
?>
</body>
</html>