I have a plugin class and I want to check on Appcontroller.structure event if a client is currently logged in. But
$this->Session->read("blesta_client_id");
returns null. This is my current code right now
<?php
class OverridesPlugin extends Plugin {
private $Record;
public function __construct() {
$this->Record = new Record();
$this->loadConfig(dirname(__FILE__) . DS . "config.json");
}
public function install($plugin_id) {
}
public function getEvents() {
return array(
array(
'event' => "Appcontroller.preAction",
'callback' => ["this", "preAction"]
),
array(
'event' => "Appcontroller.structure",
'callback' => ["this", "structure"]
),
);
}
public function preAction($event){
Loader::loadModels($this, ['Overrides.OverridesSettings']);
}
public function structure($event){
$logged_in_client = $this->Session->read("blesta_client_id");
$url_details = $event->getParams();
echo '<pre>'.var_export($logged_in_client,true).'</pre>';
exit(1);
}
}
Can you tell me what is the right way to check the client sessions in a plugin class?
Thank you