How to unserialise the PHP SESSION serialised value? -


i stored php session values dynamodb, following serialized structure getting on_session_write() function using session_set_save_handler(),

id|s:26:"rj4n98n6371vpgj8h5s10lmoh2";matt|n;smartyvalidate|a:1:{s:7:"default";a:4:{s:16:"registered_funcs";a:2:{s:8:"criteria";a:0:{}s:9:"transform";a:0:{}}s:10:"validators";a:0:{}s:8:"is_error";b:0;s:7:"is_init";b:1;}}language_id|i:1;language|s:3:"eng"; 

i tried php serialize() , unserialize() functions it's not working. so, how can un-serialize value?

i need output format per $_session printed value.

the documentation says session_set_save_handler:

while data looks similar serialize() please note different format speficied in session.serialize_handler ini setting.

the setting session.serialize_handler defaults php, means php using internal session_encode() , session_decode() functions.

session_decode() decodes serialized session data provided in $data, , populates $_session superglobal result.

example:

<?php session_start(); $str = 'id|s:26:"rj4n98n6371vpgj8h5s10lmoh2";matt|n;smartyvalidate|a:1:{s:7:"default";a:4:{s:16:"registered_funcs";a:2:{s:8:"criteria";a:0:{}s:9:"transform";a:0:{}}s:10:"validators";a:0:{}s:8:"is_error";b:0;s:7:"is_init";b:1;}}language_id|i:1;language|s:3:"eng";'; if (session_decode($str)) {   print_r($_session); } else {   die ("failed decode session"); } 

note: need initialize dummy session session_start(). otherwise session_decode() fails , not populate $_session array.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -