CodeIgniter:动态登录后重定向? [英] CodeIgniter: Dynamic post-login redirection?
问题描述
如果用户访问某个网站网址,则此类网站需要登录才能访问该网站。 :
http://www.mysite.com/project/detail/2049
,他们目前已退出,我已将其设置为自动将他们返回到登录页面。
我的问题是,他们登录后,将他们重定向到他们输入的原始网址,而不是说,将他们重定向到网站首页是什么?
我在想,也许,动态创建的URL作为一个隐藏表单元素的登录表单和重定向到那里成功登录...你们想什么?这种类型的动态登录后重定向有更好的/最佳的做法吗?
uri并将其设置为会话数据
this-> session-> set_userdata('redirect','page / uri / here' );
,然后将他们重定向到登录/注册
($ this-> session-> userdata('redirect')')检查'redirect'是否存在 ))
{
redirect($ this-> session-> userdata('redirect'));
}
I'm building a basic CodeIgniter site that requires a login before you can access any of the site.
If a user visits some site url, something like this:
http://www.mysite.com/project/detail/2049
AND they are current logged out, I have it set to automatically kick them back to the login page.
My question is, after they login, what is the best way to redirect them to the original URL they typed in, instead of say, redirecting them to the websites homepage?
I was thinking maybe, dynamically create the URL as a hidden form element in the login form and redirect there upon a successful login... What do you guys think? Is there a better/best practice for this type of dynamic post-login redirection?
When they hit the restricted page record the uri and set it as session data with
this->session->set_userdata('redirect', 'page/uri/here');
then redirect them to the login / register
after they login check to see if 'redirect' is present with
if($this->session->userdata('redirect'))
{
redirect($this->session->userdata('redirect'));
}
if it doesn't then take them wherever you normally take them after a login
这篇关于CodeIgniter:动态登录后重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!