D
D
Dmitry Cherednichenko2014-07-11 23:43:07
Kohana
Dmitry Cherednichenko, 2014-07-11 23:43:07

How to properly start a session in kohana?

Good day!
There is

abstract class Controller_Common extends Controller_Template

As well as
class Controller_Products extends Controller_Common

If I start a session in the Products controller with $session = Session::instance(); , then the subsequent entry into the session using the line $session->set('var', 'alala'); carried out. But I would like the session to be launched not only from the Products controller , but also from any other .. for example, just when switching to the default controller.
Tried to run in an abstract Common class
<?php defined('SYSPATH') or die('No direct script access.');
 
abstract class Controller_Common extends Controller_Template {
 
    public $template = 'template';
  
  public $siteName = 'Lumia Shop';
 
    public function before() {
        parent::before();
        View::set_global('title', 'Сайт');				
        View::set_global('description', 'Самый лучший сайт');
        $this->template->content = '';
        $this->template->styles = array('style'); // файлы стилей
        $this->template->scripts = array('jquery'); // файлы js
    }
} // End Common

But got an error
ErrorException [ Parse Error ]: syntax error, unexpected '(', expecting ',' or ';'

How to implement all this correctly?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question