Share PHP Rivescript object into $_SESSION

101 Views Asked by At

I have a issue trying to save an object into session.

From my index.php I create the object and store it into session:

  include_once __DIR__.'/vendor/autoload.php';
  use Axiom\Rivescript\Rivescript;
  $test = new Rivescript();
  $test->load(realpath(__KNOWLEDGE__));

  session_start();
  if (isset($_SESSION['ENGINE'])){
    unset($_SESSION['ENGINE']);
  }
  $_SESSION['ENGINE'] = $test;

in another php page I recall the session to get te object:

session_start();
if (!isset($_SESSION['ENGINE'] )){
    // error
}else{
    $test = $_SESSION['ENGINE'];
    $txt = $test->reply($input,$client_id);
}

This page is called by AJAX.

and I get this error:

Notice: Trying to get property 'memory' of non-object in /var/www/html/vendor/axiom/rivescript/src/Cortex/Input.php on line 64

Fatal error: Uncaught Error: Call to a member function substitute() on null in /var/www/html/vendor/axiom/rivescript/src/Cortex/Input.php:64 Stack trace: #0 /var/www/html/vendor/axiom/rivescript/src/Cortex/Input.php(33): Axiom\Rivescript\Cortex\Input->cleanOriginalSource() #1 /var/www/html/vendor/axiom/rivescript/src/Rivescript.php(34): Axiom\Rivescript\Cortex\Input->__construct('ciao', '5e5fe0688782a') #2 /var/www/html/include/bot.php(24): Axiom\Rivescript\Rivescript->reply('ciao', '5e5fe0688782a') #3 {main} thrown in /var/www/html/vendor/axiom/rivescript/src/Cortex/Input.php on line 64

Any help ??

0

There are 0 best solutions below