Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
[SESSION] - Create a session variable
  • Hello guys, I would like create a Session variable, and use it in my application. So I have two object (Welcome & Book). This Index's function on my Welcome page, I create my variable :
    public function action_index()
    {
     Session::set('id', '12');
    
    }
    

    It's good, because the profiler find my variable ID. Now when I go on my Book's index, I dont see my Session variable. The profiler don't find it. Why ? This is my Index's function on my Book page :
    public function action_index()
     {
      $this->template->title = Session::get('id');
      $this->template->content = View::forge('workflow/index');
     }
    

    My Session variable is NULL, why ? I use the automatic session (because auto_initialize is TRUE). Can you help me ? Thanks Djik
  • ** Moved to General **
  • Are you using cookie based sessions? Do you have a redirect after you set the session variable? Have you configured your cookie configuration properly? You need too, and make sure you are doing it correctly. For example, "localhost" is not a valid hostname as far as the RFC is concerned, and modern browsers will reject the cookie.
  • Are you using cookie based sessions? Do you have a redirect after you set the session variable?

    I don't think. I just config by default. How do you do ?
  • I never had this problem, so I wouldn't know how to reproduce it. Which version of FuelPHP? There are some issues with Sessions in 1.2 that have been fixed in 1.3, maybe try upgrading first?
  • Harro pointed out to me that the core classes should be referenced using a leading back slash:
    public function action_index() {
    $this->template->title = \Session::get('id');
    $this->template->content = View::forge('workflow/index'); }
    
    This works for me.
  • In app controllers the leading slash isn't needed, you're already in the global namespace (unless you have namespaced your app controllers).

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion