Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Use sessions codeigniter in smarty

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
StratoKyke
Smarty Rookie


Joined: 30 Apr 2015
Posts: 9

PostPosted: Thu Apr 30, 2015 9:23 am    Post subject: Use sessions codeigniter in smarty Reply with quote

Hi Smile
I'm new in smarty and I'm working with codeigniter.

I created a system login and logout that works seamlessly with smarty and I was able to transfer variables on the template.

But I was wondering if you could show something to registered users and guest users another.
I do that with an if, right?

but what?

At the moment I use this code for use variables that interest me in smarty.


Code:
public function index() {
        if($this->session->userdata('logged_in')){
           $session_data = $this->session->userdata('logged_in');
           $data['username'] = $session_data['login'];
           $this->smarty->view('home.tpl', $data);
      } else {
           redirect('user/login', 'refresh');
      }
   }


Thanks for the reply.
Back to top
View user's profile Send private message
StratoKyke
Smarty Rookie


Joined: 30 Apr 2015
Posts: 9

PostPosted: Tue May 05, 2015 8:01 am    Post subject: Reply with quote

Someone who can help me? Smile

I would that with a {if} make available part of template only to user registers.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Tue May 05, 2015 9:57 am    Post subject: Reply with quote

Your problem is the confusion of the areas of responsibility.
It is not template responsibility to decide if a user is authorized to view its contents.
It is your responsibility. You should write the code that decide what to include into the output.
Also, there's no "view()" method available in Smarty that I'm aware of.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP