-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathappend.php
More file actions
68 lines (55 loc) · 1.19 KB
/
append.php
File metadata and controls
68 lines (55 loc) · 1.19 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
<?php
/**
* Append values to a session variable.
*/
include('../src/Session.php');
$session = new Asdfdotdev\Session([
'name' => 'AppendSession',
'decoy' => false,
'min' => 5,
'max' => 10,
'debug' => true,
]);
$session->start();
/**
* About this example.
*/
echo <<<HTML
<h3>About this Example</h3>
<p style="max-width:750px;">
Each page refresh will append to both the array and string session values.
Delete the session cookie, or close your browser, to generate a new session and reset the values.
</p>
HTML;
/**
* Increment the session value.
*/
$session->appValue('my_var_string', 'text and more ');
$session->appValue('my_var_array', [rand()]);
$my_var_string = $session->getValue('my_var_string');
$my_var_array = print_r(
$session->getValue('my_var_array'),
true
);
/**
* Output results
*/
echo <<<HTML
<hr>
<h3>Session Variable</h3>
<p>
<b>String:</b> {$my_var_string}
</p>
<p>
<b>Array:</b> {$my_var_array}
</p>
HTML;
/**
* Debugging
*/
$session_content = $session->dump();
echo <<<HTML
<hr>
<h3>Debug</h3>
<pre style="overflow:scroll;">{$session_content}</pre>
HTML;