unserialize_php_session

1.0.4 • Public • Published

unserialize_php_session

unserialize_php_session is a lightweight JavaScript library for decoding serialized PHP session data. It can be used in both browser and Node.js environments

Installation

npm i unserialize_php_session

or

yarn add unserialize_php_session

or

pnpm i unserialize_php_session

Alternatively, you can include the unserialize_php_session.js file directly in your HTML:

<script src="path/to/unserialize_php_session.js"></script>

Test

npm install -force && npm test

Usage

const unserializePhpSession = require('unserialize_php_session')

const serializedData = '62kf0k2a4minrtcbr6h1l104r2|a:5:{s:3:"bar";c:4:"name":2:{s:3:"foo";i:9;}s:4:"user";s:4:"foo2";s:6:"result";b:1;s:5:"group";i:9;s:9:"is_banned";i:0;}'

const decodedData = unserializePhpSession(serializedData)

console.log(decodedData)

/* output:
{
   '62kf0k2a4minrtcbr6h1l104r2': [
      bar: {
        name: [Array]
      },
      user: 'foo2',
      result: true,
      group: 9,
      is_banned: 0
    ]
}
*/
More example can see output of testing. test/index.js

API

unserializer(text: string): object

Decodes serialized PHP data and returns a JavaScript object.


Contributing

####Pull requests and bug reports are welcome! If you'd like to contribute, please follow these guidelines:

1. Fork the repository.
2. Create a new branch for your changes.
3. Make your changes and add tests if applicable.
4. Run npm test to ensure that all tests pass.
5. Submit a pull request.

By contributing to this project, you agree to license your work under the same terms as the project itself (MIT).

Package Sidebar

Install

npm i unserialize_php_session

Weekly Downloads

0

Version

1.0.4

License

MIT

Unpacked Size

8.69 kB

Total Files

4

Last publish

Collaborators

  • shantoislam6