The PHP session handler by default stores session data in serialize() format in a file, which means that it is mostly textual. You can, of course, manipulate the file from the command line using any of the standard UNIX text tools (Perl, Sed, AWK, even an echo / cat in a shell script, etc ...), as long as you donβt "t insert syntax error into serialized data.
But at that moment, if you do not find a function / library / module that does unserialize() and most likely serialize() , as well, you can also just do the PHP manipulations yourself. This would be a fairly rare system that does not have a CLI version for PHP installed next to the web server version.
$dat = file_get_contents('/path/to/session/file'); $session = unserialize($dat); $session['temp'] = 'whatever'; $dat = serialize($session); file_put_contents('/path/to/session/file', $dat);
source share