mattrmiller / phalcon-dbsessionadapter

Phalcon PHP - Database Session adapter using a Model written in PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

phalconphp-dbsessionadapter

Phalcon PHP - Database Session adapter using a Model.

Installation

  1. Copy Code into Respective Folders
  • /app/Library/*
  • /app/Models/*
  1. Database Table
CREATE TABLE `sessions` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `uuid` varchar(64) NOT NULL DEFAULT '',
  `data` longtext NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `modified_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uuid` (`uuid`),
  KEY `created_at` (`created_at`),
  KEY `modified_at` (`modified_at`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
  1. Setup Service
$di->set('session', function () use ($oConfig) {

		// Sessions
		return new DbSessionAdapter(array(
			'name' => 'myawesomeapplication',
			'domain' => 'myawesomeapplication.com',
			'secure' => 1,
			'use_cookies' => 1,
			'hash' => 'sha256',
			'lifetime' => 0
		));

	});
  1. Use Like Regular Phalcon Sessions
$this->session->set('enjoy_our_code', 'ok');

Rules For Contributing

  • Please make sure all changed files are run through gofmt
  • Submit a PR for review
  • Your name will be added below to Contributors

Author

Matthew R. Miller

Contributors

Matthew R. Miller

License

MIT License

About

Phalcon PHP - Database Session adapter using a Model written in PHP

License:MIT License


Languages

Language:PHP 100.0%