PHPSession
Simple module to manipulate PHP session vars ($_SESSION) stored in JSON, using memcached
CAREFUL: this is NEW version of memcache !
Install
Install with npm:
npm install phpsession
Basic Usage
Require the module:
PHPSESSION = require 'phpsession'
Instantiate with URL:
sess =
Method usage:
Connect to server:
sessconnect host: 127.00.1 # Default value port: 11211 # Default value
Check server is connected
if sessisConnected consolelog 'All right !!'
Retrieve $_SESSION value:
sessget id: '9eir0ul21knvmlhu0a4kleh8j1' consolelog data
Define a $_SESSION var:
sessset id: '9eir0ul21knvmlhu0a4kleh8j1' data: 'hello': 'world' lifetime: 1440
Replace a $_SESSION var:
sessreplace id: '9eir0ul21knvmlhu0a4kleh8j1' data: 'hello': 'world' lifetime: 1440
Refresh a $_SESSION:
sessrefresh id: '9eir0ul21knvmlhu0a4kleh8j1' lifetime: 1440
Update specific $_SESSION key:
sessupdate id: '9eir0ul21knvmlhu0a4kleh8j1' key: 'hello' value: 'better world' lifetime: 1440
Delete $_SESSION id:
sessdelete id: '9eir0ul21knvmlhu0a4kleh8j1'
Extended usage
All methods supports callback parameters:
sessset id: '9eir0ul21knvmlhu0a4kleh8j1' data: 'hello': 'better world' consolelog "Received: " # Do something with result...
Run tests
You can run unit-tests using mocha with:
npm test