codeigniter 由于重定向而丢失会话,有办法重新生成它吗?
我有一个表单,其中包含预览按钮和提交按钮。假设该表单包含一个人的数据。单击预览会将表单提交到 example.com/preview 并在新选项卡中将其打开。预览控制器会将人员的数据插入表中,并根据 LAST_INSERT_ID() 的值重定向到 example.com/person/ID。发生重定向时,所有会话数据都会丢失。我希望能够保留会话数据,以便在检查 example.com/person/ID 页面时,管理员用户可以关闭它并对表单进行一些更改或提交。
我注意到将会话 ID 存储在 flashdata 项中不起作用,它不会通过重定向。另外,如果我设法通过重定向获取 session_id (尽管将其添加到 url 不是我的客户想要的),我仍然不知道如何用它重新生成 Codeigniter 会话。我研究过的另一个选择是使用 Codeigniter Native Session 类,但我在网站上找到的版本不适用于 Codeigniter 2.0.0.3,而且我担心使用它可能会破坏某些内容。
非常感谢任何建议。
I've got a form that has, among other things, a preview button and a submit button. Let's say that the form contains a person's data. Clicking preview will submit the form to example.com/preview and get it opened in a new tab. The preview controller will insert the person's data in a table and, based on the value of LAST_INSERT_ID(), it will redirect to example.com/person/ID. When the redirect occurs, all session data is lost. I want to be able to keep session data so that, upon checking the example.com/person/ID page, the admin user can close it and do some changes to the form or submit it.
I've noticed that storing the session id in a flashdata item won't work, it won't get past the redirect. Also, if i somehow manage to get the session_id past the redirect (although adding it to the url is not what my client wants), I still don't know a way to regenerate the Codeigniter session with it. Another option I've looked into is using Codeigniter Native Session class, but the version I've found on the site is not for Codeigniter 2.0.0.3, and I'm afraid that using it might break something.
Any advice is much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案是将我的 ci_sessions 数据库表字段的排序规则更改为 utf8_general_ci (默认为 latin1_swedish_ci)
The solution was to change my ci_sessions database table fields' collations to utf8_general_ci (the default was latin1_swedish_ci)