简体   繁体   English

在 CakePHP 中禁用 Session 重定向

[英]Disable Session redirect in CakePHP

On a CakePHP app when a user logs in, it redirects the user to either a previous visited action that requires authentication or to a default location specified by loginRedirect but all of this is hidden in the session value and stored until deleted.在 CakePHP 应用程序上,当用户登录时,它会将用户重定向到需要身份验证的先前访问的操作或loginRedirect指定的默认位置,但所有这些都隐藏在 session 值中并存储直到删除。

I would like to disable this and instead replace it with query strings in the url such as for example domain.com/users/login?back?=/posts/add我想禁用它,而是用 url 中的查询字符串替换它,例如domain.com/users/login?back?=/posts/add

This is to make sure the user always knows what they are trying to access and prevents them from being sent to locations that are saved in the session from previous visits and may not necessarily be the location they wish to visit...这是为了确保用户始终知道他们正在尝试访问的内容,并防止他们被发送到以前访问时保存在 session 中的位置,并且可能不一定是他们希望访问的位置...

Can anyone help?任何人都可以帮忙吗? Thanks谢谢

EDIT: I have disbaled autoRedirect which DOES disable the Auth.redirect session key so now I need to build my own query string can anyone help with this?编辑:我已经禁用了自动重定向,它确实禁用了 Auth.redirect autoRedirect键,所以现在我需要构建自己的查询字符串,有人可以帮忙吗?

in $this->Form->create() pass the url option with $this->referer() in it as a param, you will need to url encode it I guess.在 $this->Form->create() 中传递 url 选项,其中 $this->referer() 作为参数,我猜你需要 url 对其进行编码。

you can then pick it up again in the login action and use $this->redirect($thatParam) to do there.然后,您可以在登录操作中再次选择它并使用 $this->redirect($thatParam) 来执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM