Registry / storage / php-session-unserialize

php-session-unserialize

JSON →
library0.2.2jsnpmunverified

Converts PHP session strings (stored in Redis or elsewhere) into JavaScript objects. Version 0.2.2 processes PHP session format including session ID prefix and serialized PHP data. Lightweight utility with no dependencies, supports Node.js 4+. Unlike full PHP serialization libraries, this focuses solely on session deserialization and handles common edge cases like nested arrays and objects. Low release cadence; browser support listed as TODO.

npm install php-session-unserialize
INSTALL
IMPORT
SIG · PHP-SESSION-UNSERI
P
php-session-unserialize
storagejavascriptv0.2.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

unserializer
const unserializer = require('php-session-unserialize')
import unserializer from 'php-session-unserialize'
Package does not provide ESM exports; use CommonJS require.
default import (function)
const parse = require('php-session-unserialize')
const { unserialize } = require('php-session-unserialize')
Direct call to the required function; not a named export.
invocation
const result = parse(sessionString)
new parse(sessionString)
It's a plain function, not a constructor.

Parses a PHP session string (with session ID) into a JavaScript object using the default export function.

const parser = require('php-session-unserialize'); const session = 'sessionid123|a:2:{s:3:"foo";s:3:"bar";s:3:"baz";i:42;}'; const result = parser(session); console.log(result); // { sessionid123: { foo: 'bar', baz: 42 } }
Debug
Known issues
gotchaFunction expects a session string with a leading session ID and pipe separator. If input lacks pipe, parsing may fail silently.
fix
Ensure input is in 'sessionId|serializedData' format.
affects: >=0.0.0
gotchaDoes not support PHP serialized objects (O:...) or references (R:). Only handles scalars, arrays, and strings.
fix
Use a more comprehensive PHP serialization parser for full support.
affects: >=0.0.0
gotchaUnknown unserialization types (e.g., c for custom class) may produce incomplete results.
fix
Check the source code for supported types; submit a PR for missing ones.
affects: >=0.0.0
gotchaSemicolons inside string values may break parsing.
fix
Escape or encode semicolons in PHP session data.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: parser is not a function
Using default import syntax with ESM (e.g., import parser from 'php-session-unserialize') in a CommonJS-only package.
fix
Use require: const parser = require('php-session-unserialize')
Cannot read property 'split' of undefined
Input session string is empty or undefined.
fix
Check that session string is provided and is a non-empty string.
Upgrade
Version history
0.2.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
Amazon
1
Resources
php-session-unserialize — npm install php-session-unserialize · libregistry