php_session_decoder

package module
v0.0.0-...-16ce1f6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2015 License: BSD-2-Clause Imports: 5 Imported by: 0

README

php_session_decoder

PHP session encoder/decoder written in Go
Build Status

Installation

Install:

  • The recommended way to install is using gonuts.io:

    nut get yvasiyarov/php_session_decoder for more information, please, go to the http://www.gonuts.io/yvasiyarov/php_session_decoder

  • Using default go get tool:

    go get github.com/yvasiyarov/php_session_decoder

Getting started

Example: load php session data from redis:

if sessionId, err := req.Cookie("frontend"); err == nil {
    if sessionData, err := redis.Get("PHPREDIS_SESSION:" + sessionId.Value); err == nil {
        decoder := php_session_decoder.NewPhpDecoder(sessionData.String())
        if sessionDataDecoded, err := decoder.Decode(); err == nil {
            //Do something with session data  
        }
    } else {
        //Can not load session - it can be expired
    }
}

Example: Encode php session data:

data := make(PhpSession)
data["make some"] = " changes"
encoder := NewPhpEncoder(data)
if result, err := encoder.Encode(); err == nil {
    //Write data to redis/memcached/file/etc
}

2013-2014 Yuriy Vasiyarov
2014 Yuriy Vasiyarov, Maksim Naumov.

All rights reserved.

Documentation

Overview

Package php_session_decoder provides possibility to decode/encode php session data in php_binary format.

Index

Constants

View Source
const SEPARATOR_VALUE_NAME rune = '|'

Variables

This section is empty.

Functions

This section is empty.

Types

type PhpDecoder

type PhpDecoder struct {
	// contains filtered or unexported fields
}

func NewPhpDecoder

func NewPhpDecoder(phpSession string) *PhpDecoder

func (*PhpDecoder) Decode

func (self *PhpDecoder) Decode() (PhpSession, error)

func (*PhpDecoder) SetSerializedDecodeFunc

func (self *PhpDecoder) SetSerializedDecodeFunc(f php_serialize.SerializedDecodeFunc)

type PhpEncoder

type PhpEncoder struct {
	// contains filtered or unexported fields
}

func NewPhpEncoder

func NewPhpEncoder(data PhpSession) *PhpEncoder

func (*PhpEncoder) Encode

func (self *PhpEncoder) Encode() (string, error)

func (*PhpEncoder) SetSerializedEncodeFunc

func (self *PhpEncoder) SetSerializedEncodeFunc(f php_serialize.SerializedEncodeFunc)

type PhpSession

type PhpSession map[string]php_serialize.PhpValue

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL