1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10:
11:
12: namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
13:
14: 15: 16: 17: 18:
19: class WriteCheckSessionHandler implements \SessionHandlerInterface
20: {
21: 22: 23:
24: private $wrappedSessionHandler;
25:
26: 27: 28:
29: private $readSessions;
30:
31: public function __construct(\SessionHandlerInterface $wrappedSessionHandler)
32: {
33: $this->wrappedSessionHandler = $wrappedSessionHandler;
34: }
35:
36: 37: 38:
39: public function close()
40: {
41: return $this->wrappedSessionHandler->close();
42: }
43:
44: 45: 46:
47: public function destroy($sessionId)
48: {
49: return $this->wrappedSessionHandler->destroy($sessionId);
50: }
51:
52: 53: 54:
55: public function gc($maxlifetime)
56: {
57: return $this->wrappedSessionHandler->gc($maxlifetime);
58: }
59:
60: 61: 62:
63: public function open($savePath, $sessionName)
64: {
65: return $this->wrappedSessionHandler->open($savePath, $sessionName);
66: }
67:
68: 69: 70:
71: public function read($sessionId)
72: {
73: $session = $this->wrappedSessionHandler->read($sessionId);
74:
75: $this->readSessions[$sessionId] = $session;
76:
77: return $session;
78: }
79:
80: 81: 82:
83: public function write($sessionId, $data)
84: {
85: if (isset($this->readSessions[$sessionId]) && $data === $this->readSessions[$sessionId]) {
86: return true;
87: }
88:
89: return $this->wrappedSessionHandler->write($sessionId, $data);
90: }
91: }
92: