Hello I want to do redirect a page if a user is not logined or not admin and return to the start page. I can redirect to login page:
ee()->output->set_header("Location: http://example.com/admin.php?S=0&D=cp&C=login&return;=");But I can’t understand what should I put in “&return;=??????” so that the user return to the start page. I tried
"&return=http://example.com/startpage"(urlencoded of course) but it doesn’t work (Disallowed key characters) I noticed that EE put there some code like:
&return=Qz1hZG1pbl9jb250ZW50JmFtcDtNPWNoYW5uZWxfbWFuYWdlbWVudA==So what is the code and how can I encode a link to that code? Thank you!
First of all create a session and set logged in user data like
[quote] $this->load->model('membership_model');
$query = $this->membership_model->validate();
if($query) // if the user’s credentials validated… { $data = array( ‘username’ => $this->input->post(‘username’), ‘is_logged_in’ => true ); echo $this->session->set_userdata($data); redirect(‘site/member_profile’);
} else // incorrect username or password { $this->index(); }
after that put these line in the constructor of every controller
if(!is_logged_in()) { redirect(‘login’); // loginis the controller name }
Hope so this will help you.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.