summaryrefslogtreecommitdiff
path: root/tests/session/sessionhandler.inc
diff options
context:
space:
mode:
authorStefan Esser2014-02-15 12:13:19 +0100
committerStefan Esser2014-02-15 12:13:19 +0100
commit71c70de8df61ff1446efb1c168d3c2deccf58586 (patch)
treec157eb11e83912026f2f4fbe72681d0c729ad92b /tests/session/sessionhandler.inc
parentd556e8afdd33cbe89ed2f3f4e2d0700e495dadc9 (diff)
Add a bunch of session id / session encryption tests from Ben.
Diffstat (limited to 'tests/session/sessionhandler.inc')
-rw-r--r--tests/session/sessionhandler.inc41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/session/sessionhandler.inc b/tests/session/sessionhandler.inc
new file mode 100644
index 0000000..31b7546
--- /dev/null
+++ b/tests/session/sessionhandler.inc
@@ -0,0 +1,41 @@
1<?php
2class GenericSessionHandler implements SessionHandlerInterface
3{
4 function open($savePath, $sessionName) { return true; }
5
6 function close() { return true; }
7
8 function read($id) { return (string)""; }
9
10 function write($id, $data) { return true; }
11
12 function destroy($id) { return true; }
13
14 function gc($maxlifetime) { return true; }
15
16}
17class WriteSessionHandler extends GenericSessionHandler
18{
19 function write($id, $data)
20 {
21 echo "SESSION: $data\n";
22 return true;
23 }
24}
25class RemoteAddrSessionHandler extends GenericSessionHandler
26{
27 ## key empty and REMOTE_ADDR set to 127.0.0.1
28 function read($id) { return (string)"j1YTvIOAUqxZMjuJ_ZnHPHWY5XEayycsr7O94aMzmBQ."; }
29}
30
31
32function session_test_start($handler=null) {
33 if (!$handler) {
34 $handler = new WriteSessionHandler();
35 }
36 session_set_save_handler($handler, true);
37 session_start();
38 return $handler;
39}
40
41?>