PHP code example of fmihel / ajax-plugin-session

1. Go to this page and download the library: Download fmihel/ajax-plugin-session library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fmihel / ajax-plugin-session example snippets




use fmihel\ajax\plughin\session\SessionDefault;

class MySession extends SessionDefault{

    function __construct()
    {
        $this->users = [
            ['id' => '1', 'login' => '1', 'pass' => '1', 'sid' => '3992', 'rights' => ['admin']],
            ['id' => '2', 'login' => '2', 'pass' => '2', 'sid' => '3993', 'rights' => ['manager']],
        ];
    }

}


re_once __DIR__ . '/server/session/MySession.php';

use fmihel\ajax\ajax;
use fmihel\ajax\plugin\session\SessionPlugin;

if (ajax::enabled()) {
    try {

        ajax::init([
            'plugins' => [
                new SessionPlugin('MySession'),
            ]
        ]);
        


    use fmihel\ajax;
    error_log(print_r(ajax::data(),true));
    ajax::out('hi, from server');
    

path
  |-server
  |   |-session
  |   |    |-MySession.php
  |   |-mod.php
  |-index.php
  |
  |-client
      |-index.js
      |-session.js
server/session/MySession.php
index.php
server/mod.php