0.2.0 • Published 7 years ago

phpsession v0.2.0

Weekly downloads
1
License
Apache-2.0
Repository
github
Last release
7 years ago

PHPSession

NPM

Downloads per month npm version Build Status Dependencies

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 = 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
0.2.0

7 years ago

0.1.6

8 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago