Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7033799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:06:31+00:00 2026-05-28T01:06:31+00:00

Let me try to explain what I want to do here. I am trying

  • 0

Let me try to explain what I want to do here. I am trying to re-write a pet project from Codeigniter 2.x to Kohana 3.2.x.

I have created a Site Template controller (below)

class Controller_Site_Template extends Controller_Template 
  {

      public $template      = 'templates/hero';

      /**
       * The before() method is called before your controller action.
       * In our template controller we override this method so that we can
       * set up default values. These variables are then available to our
       * controllers if they need to be modified.
       */
      public function before()
      {
          parent::before();

        if ($this->auto_render)
        {
            // Initialize empty values
            $this->template->title   = '';
            $this->template->content = '';
            $this->template->session = '';

            $this->template->styles = array();
            $this->template->footer_scripts = array();

          $session = Session::instance();
          $this->template->session = $session;

        }

      }

      /**
       * The after() method is called after your controller action.
       * In our template controller we override this method so that we can
       * make any last minute modifications to the template before anything
       * is rendered.
       */
      public function after()
      {
            if ($this->auto_render)
            {
                $styles = array(
                    'assets/css/style.css' => 'screen',);


                $footer_scripts = array(
                                    'assets/js/libs/jquery-1.7.1.min.js',
                    'assets/js/application.js',
                );

                $this->template->styles = array_merge( $this->template->styles, $styles );
                $this->template->footer_scripts = array_merge( $this->template->footer_scripts, $footer_scripts );
            }

            parent::after();
      }

After the login form is submitted I set the session data and I am able to retrieve the session data in the Controllers that extend the Controller_Site_Template but I am unable to retrieve the session data in any of the View files.

The only way I am able to get the session data in the view files is to pass the session data in each controller that extends the Template_Site_Template:

$this->template->content->set_global('session',$this->template->session->as_array());

Is there an easy way to establish and set the session in the template_controller that can be used in all of the controllers, modelc, views rather that using the set_global on each individual controller?

I don’t know if I am explaining this well but I am used to the ease of Codeigniter’s $this->session->userdata(); function that can be called in any controller, model, and view once it was set.

Thank you in advance for any input on what I am doing incorrectly.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:06:32+00:00Added an answer on May 28, 2026 at 1:06 am

    You can set or bind global data to your views with the following

    View::bind_global('session', $session);
    View::set_global('session', $session);
    

    If you plan to change any data further along the application logic, then use bind.

    If no more changes to the data are required, use set.

    Edit: oh, the above is just for views and you want it across the entire application.

    Just use the Session::instance()->set() and Session::instance()->get() as required across your application rather then assigning it in your application controller.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let me try to explain what I need. I have a server that is
Let me try and explain this. Within a project folder has .m and .h
Let me try and explain what I want to achieve. I want X boxes
Let me try to explain... Lets say I have the following 'a' tags on
Let me try to explain it. Please tell me if I am wrong. I
Alright so I have a task, that I have to let the client try
So here's my issue. I have a binary file that I want to edit.
Let me try to explain the situation the best I can. Lets say I
Ok, so let me explain a little of what I am trying to do.
I got stuck with this scenario. Let me explain as follows. I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.