我想在用户登录 opencart-3.0.2.0 后设置会话
我是opencart的新手,我刚刚在相应的文件夹中创建了这两个文件。我需要做任何其他事情来触发事件。
我指的是这个链接来触发opencart中的事件:https ://isenselabs.com/posts/opencart2-event-system-tutorial
我在谷歌上搜索了很多仍然没有找到结果。
我用来在 opencart 中触发事件的代码。
路径:管理员/控制器/模块/mymodule.php
代码 :
public function install() {
$this->load->model('extension/event');
$this->model_extension_event->addEvent('mymodule', 'pre.admin.store.delete', 'module/mymodule/on_store_delete');
$this->model_extension_event->addEvent('mymodule', 'post.customer.login', 'module/mymodule/post_customer_login_customtoken');
$this->model_extension_event->addEvent('mymodule', 'post.customer.logout', 'module/mymodule/post_customer_logout_function');
}
public function uninstall() {
$this->load->model('extension/event');
$this->model_extension_event->deleteEvent('mymodule');
}
public function on_store_delete($store_id) {
$this->load->model('setting/store');
$store_info = $this->model_setting_store->getStore($store_id);
$admin_mail = $this->config->get('config_email');
mail($admin_mail, "A store has been deleted", "The store " . $store_info['url'] . " was deleted.");
}
}
路径:目录/控制器/模块/mymodule.php
代码 :
<?php
class ControllerModuleMyModule extends Controller {
public function post_customer_login_customtoken() {
$str = 'abcdefghigklmnopqrstuvwxyz';
$shuffled = str_shuffle($str);
$this->session->data['custom_token'] = $shuffled;
}
public function post_customer_logout_function(){
$this->log->write("post_customer_logout_function");
unset($this->session->data['custom_token']);
}
}