Skip to content

x42en/PHPSession

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHPSession

NPM

Downloads per month npm version Build Status Dependencies Known Vulnerabilities

Simple module to manipulate PHP session vars ($_SESSION) stored in JSON, using memcached

CAREFUL: this is NEW version of memcache !

Important: This package is NOT backward compatible with 0.1.x versions... Be careful if you update your npm project...

Install

Install with npm:

  npm install phpsession

Basic Usage

Require the module:

  PHPSESSION = require 'phpsession'

Instantiate:

  sess = new PHPSESSION()

Method usage:

Connect to server:

  sess.connect
    host: 127.0.0.1  # Default value
    port: 11211      # Default value

Check server is connected

  if sess.isConnected()
    console.log 'All right !!'

Retrieve $_SESSION value:

  sess.get
    id: '9eir0ul21knvmlhu0a4kleh8j1'
    ,(data) -> console.log data

Define a $_SESSION var:

  sess.set
    id: '9eir0ul21knvmlhu0a4kleh8j1'
    data: { 'hello': 'world' }
    lifetime: 1440

Replace a $_SESSION var:

  sess.replace
    id: '9eir0ul21knvmlhu0a4kleh8j1'
    data: { 'hello': 'world' }
    lifetime: 1440

Refresh a $_SESSION:

  sess.refresh
    id: '9eir0ul21knvmlhu0a4kleh8j1'
    lifetime: 1440

Update specific $_SESSION key:

  sess.update
    id: '9eir0ul21knvmlhu0a4kleh8j1'
    key: 'hello'
    value: 'better world'
    lifetime: 1440

Delete $_SESSION id:

  sess.delete
    id: '9eir0ul21knvmlhu0a4kleh8j1'

Extended usage

All methods supports callback parameters:

  sess.set
    id: '9eir0ul21knvmlhu0a4kleh8j1'
    data: { 'hello': 'better world' }
    , (res) ->
      console.log "Received: #{res}"
      # Do something with result...

Run tests

You can run unit-tests using mocha with:

  npm test

About

Manage PHP $_SESSION var stored in JSON with node.js, using memcached server

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published