|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
StratoKyke Smarty Rookie
Joined: 30 Apr 2015 Posts: 9
|
Posted: Thu Apr 30, 2015 9:23 am Post subject: Use sessions codeigniter in smarty |
|
|
Hi
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 |
|
StratoKyke Smarty Rookie
Joined: 30 Apr 2015 Posts: 9
|
Posted: Tue May 05, 2015 8:01 am Post subject: |
|
|
Someone who can help me?
I would that with a {if} make available part of template only to user registers. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Tue May 05, 2015 9:57 am Post subject: |
|
|
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 |
|
|
|
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
|