CakePHP 1.3 中基于 jQuery 的 AJAX 会话
首先,因为我只有很少的 JS/jQuery 经验,所以这整个事情对我来说将是一个学习曲线 - 所以请原谅我可能会问的任何愚蠢问题:)
我有一个交互式小说网站,用户可以在其中使用可以向故事提交自己的章节。我遇到的问题之一是,用户的会话有时会在完成章节编写之前超时,这意味着当他们提交时,他们会注销(然后再次登录,见下文),并丢失所有工作。 ..不好。
我确实设置了 cookie 并使用 自动登录,尽管这没有解决问题(用户提交表单后重新登录,但表单内容消失)。
因此,为了解决这个问题,我认为使用 jQuery AJAX 在输入时执行某种类型的自动保存可能是个好主意。
这个想法是,表单的内容每隔几秒就会自动保存在会话变量数组中,理论上,它会做两件事 - 首先,它将使会话保持活动状态,这意味着它不会超时,第二,这意味着他们可以离开页面,然后返回该页面,到目前为止他们编写的所有内容都会自动填充到该页面中。
问题是我不知道如何开始这样的努力,这就是为什么我希望这里的某个好心人能够为我指明正确的方向?
谢谢。
First of all, because I've got very little JS/jQuery experience, this entire thing will be a learning curve for me - so please excuse any dumb questions that I may ask :)
I've got an interactive fiction site on which users can submit their own chapters to stories. One of the problems I have is that the user's session can sometimes times out before they're finished writing the chapter, meaning when they submit, they're logged out (then logged in again, see below), and loose all their work... Not good.
I do have a cookie set and use autologin, though this doesn't solve the problem (the user is re-logged in after submitting the form, but the content of the form vanishes).
So, in an effort to solve this problem, I thought it could be a good idea to use jQuery AJAX to perform some type of auto-save as they're typing.
The idea is that the content of the form gets automatically saved in a session variable array every few seconds, which, in theory, does two things - first, it will keep the session active, meaning that it won't time out, and second, it means they can leave the page, then return to it, with everything they've written so far being auto-populated into it.
The problem is that I don't know how to get started on such an endeavour, which is why I was hoping that some kind soul here might be able to point me in the right direction?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最简单的解决方案是将会话过期时间更改为几个小时
Configure::write('Session.timeout', '144');
并保留会话中章节内容的值,直到按保存按钮。Simplest solution is change session expire time to couple of hours
Configure::write('Session.timeout', '144');
and hold the values of chapter contents in session and until the press save button.