novemb3r/nginx-uid-decoder

A simple library to decode/encode uid from ngx_http_userid_module


Keywords
decode, cookie, nginx, UID, ngx_http_userid_module, uid_got, uid_set, decoder, ngx-http-userid, php
License
MIT

Documentation

Nginx uid decoder

packagist-dt-badge release-version-badge php-version-badge code-climate-maintainability-badge license

A simple library to decode/encode uid from ngx_http_userid_module

Based on Alain Tiemblo answer on stackoverflow

When you use ngx_http_userid_module cookies set to variables $uid_got and $uid_set has format that differs from the one you get from user cookies. So, you have to decode them to compare.

Examples

 NginxUidDecoder::decodeCookie('CqCx7E5qMNUxrmAUAwMJAg==');
 // 'ECB1A00AD5306A4E1460AE3102090303'

 NginxUidDecoder::encodeUid('ECB1A00AD5306A4E1460AE3102090303');
 // 'CqCx7E5qMNUxrmAUAwMJAg=='

Installing

This library installs as a composer package with

$ composer require novemb3r/nginx-uid-decoder

or

{
    "require": {
        "novemb3r/nginx-uid-decoder": "dev-master"
    }
}

Testing

To execute test suites run

$ composer test