@@ -182,7 +182,7 @@ public function sessionRead($id)
182
182
$ sessionRows = $ stmt ->fetchAll (\PDO ::FETCH_NUM );
183
183
184
184
if (count ($ sessionRows ) == 1 ) {
185
- return $ sessionRows [0 ][0 ];
185
+ return base64_decode ( $ sessionRows [0 ][0 ]) ;
186
186
}
187
187
188
188
// session does not exist, create it
@@ -218,9 +218,11 @@ public function sessionWrite($id, $data)
218
218
: "UPDATE $ dbTable SET $ dbDataCol = :data, $ dbTimeCol = :time WHERE $ dbIdCol = :id " ;
219
219
220
220
try {
221
+ //session data can contain non binary safe characters so we need to encode it
222
+ $ encoded = base64_encode ($ data );
221
223
$ stmt = $ this ->db ->prepare ($ sql );
222
224
$ stmt ->bindParam (':id ' , $ id , \PDO ::PARAM_STR );
223
- $ stmt ->bindParam (':data ' , $ data , \PDO ::PARAM_STR );
225
+ $ stmt ->bindParam (':data ' , $ encoded , \PDO ::PARAM_STR );
224
226
$ stmt ->bindValue (':time ' , time (), \PDO ::PARAM_INT );
225
227
$ stmt ->execute ();
226
228
@@ -252,9 +254,11 @@ private function createNewSession($id, $data = '')
252
254
253
255
$ sql = "INSERT INTO $ dbTable ( $ dbIdCol, $ dbDataCol, $ dbTimeCol) VALUES (:id, :data, :time) " ;
254
256
257
+ //session data can contain non binary safe characters so we need to encode it
258
+ $ encoded = base64_encode ($ data );
255
259
$ stmt = $ this ->db ->prepare ($ sql );
256
260
$ stmt ->bindParam (':id ' , $ id , \PDO ::PARAM_STR );
257
- $ stmt ->bindParam (':data ' , $ data , \PDO ::PARAM_STR );
261
+ $ stmt ->bindParam (':data ' , $ encoded , \PDO ::PARAM_STR );
258
262
$ stmt ->bindValue (':time ' , time (), \PDO ::PARAM_INT );
259
263
$ stmt ->execute ();
260
264
0 commit comments