首页 \ 问答 \ CodeIgniter 3重定向功能不起作用(CodeIgniter 3 redirect function not working)

CodeIgniter 3重定向功能不起作用(CodeIgniter 3 redirect function not working)

我正在重新编码和更新我的CMS我已经在CI2工作到CI3,而在我的生活中我无法让我的重定向功能在CI3上为我工作。

除了重新设计我的模型之外,到目前为止,我的代码与我的CI2代码完全相同。 本来我怀疑我的布局钩子是罪魁祸首,但我完全禁用了他,我仍然没有到达任何地方。

public function login ()
{
    //var_dump(logged_in());
    //if (logged_in())
        redirect('/user/');
}

以上是我的用户控制器当前的整个登录功能。 为了找出这个问题,我已经删除了所有其他代码。 我甚至评论过if语句,认为它甚至可能是罪魁祸首。 不。

我的logged_in()函数返回TRUE或FALSE,具体取决于我的用户会话中设置的某些内容。 这似乎运作正常。 据我所知,我的配置设置看起来不错。 我有自动加载的URI帮助程序,其他URI帮助程序方法正常运行。

现在为了奇怪的部分。 当我访问/ user / login时,不仅我的页面没有重定向,如果我在重定向之前取消注释var_dump() (返回true),并重新评论它,页面不会更新,我有bool(true)在我的屏幕上无论如何。 如果var_dump被注释,我打开一个新的选项卡给users/login它根本不加载任何东西,它只是挂起作为一个新的选项卡。

编辑 :我忘了提到当我使用'refresh'标志( redirect('/user/', 'refresh'); ),这只是带我到about:空白页面。

编辑#2 :我已经将CI3文件复制到一个新的“项目”中,甚至那些不会使用内置的Welcome_Message视图/控制器组合重定向。


I'm in the process of re-coding and updating my CMS I've got working in CI2, to CI3, and for the life of me I cannot get my redirect function to work for me on CI3.

Outside of redesigning my Models, my code thus far is is identical to my CI2 code. Originally I suspected my layout hook was the culprit, but I've completely disabled him and I'm still not getting anywhere.

public function login ()
{
    //var_dump(logged_in());
    //if (logged_in())
        redirect('/user/');
}

Above is the entirety of my login function at the moment, from my User controller. I've removed all the other code in an effort to pinpoint this problem. I've even commented out the if statement thinking that it might even by the culprit. nope.

My logged_in() function returns TRUE, or FALSE, depending on certain things set in my user sessions. That appears to be functioning fine. As far as I can tell, my configs settings looks good. I have the URI helper autoloaded, and other URI helper methods function properly.

Now for the strange part. When I visit /user/login, not only does my page not redirect, if I un-comment the var_dump() before the redirect (which returns true), and re-comment it, the page doesn't update, and I have bool(true) on my screen regardless. If the var_dump is commented and I open a new tab to users/login it simply doesn't load anything, and it just hangs out as a new tab.

Edit: I've forgotten to mention that when I use the 'refresh' flag (redirect('/user/', 'refresh');), that simply takes me to an about:blank page.

Edit#2: I've copied the CI3 files into a new "project", and even those wont redirect using the built in Welcome_Message view/controller combo.


原文:https://stackoverflow.com/questions/33686117
更新时间:2022-05-16 17:05

最满意答案

我认为你有一个语法错误: $(window).resize(checkSize); 应该

$(window).resize(function(){
    checkSize();
});

这种修正对我没有任何其他改变。


I think you have a syntax error: $(window).resize(checkSize); should be

$(window).resize(function(){
    checkSize();
});

That correction worked for me with no other changes.

相关问答

更多

相关文章

更多

最新问答

更多
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)
  • 是否可以嵌套hazelcast IMaps?(Is it possible to nest hazelcast IMaps? And whick side effects can I expect? Is it a good Idea anyway?)
  • UIViewAnimationOptionRepeat在两个动画之间暂停(UIViewAnimationOptionRepeat pausing in between two animations)
  • 在x-kendo-template中使用Razor查询(Using Razor query within x-kendo-template)
  • 在BeautifulSoup中替换文本而不转义(Replace text without escaping in BeautifulSoup)
  • 如何在存根或模拟不存在的方法时配置Rspec以引发错误?(How can I configure Rspec to raise error when stubbing or mocking non-existing methods?)
  • asp用javascript(asp with javascript)
  • “%()s”在sql查询中的含义是什么?(What does “%()s” means in sql query?)
  • 如何为其编辑的内容提供自定义UITableViewCell上下文?(How to give a custom UITableViewCell context of what it is editing?)
  • c ++十进制到二进制,然后使用操作,然后回到十进制(c++ Decimal to binary, then use operation, then back to decimal)
  • 以编程方式创建视频?(Create videos programmatically?)
  • 无法在BeautifulSoup中正确解析数据(Unable to parse data correctly in BeautifulSoup)
  • webform和mvc的区别 知乎
  • 如何使用wadl2java生成REST服务模板,其中POST / PUT方法具有参数?(How do you generate REST service template with wadl2java where POST/PUT methods have parameters?)
  • 我无法理解我的travis构建有什么问题(I am having trouble understanding what is wrong with my travis build)
  • iOS9 Scope Bar出现在Search Bar后面或旁边(iOS9 Scope Bar appears either behind or beside Search Bar)
  • 为什么开机慢上面还显示;Inetrnet,Explorer
  • 有关调用远程WCF服务的超时问题(Timeout Question about Invoking a Remote WCF Service)