简体   繁体   English

如果用户未使用Jquery AJAX登录,如何加载内部日志记录页面

[英]How load an internal logging page if user not logged in Using Jquery AJAX

I am trying to implement a logging-redirect page without losing the current page's data. 我正在尝试实现一个日志重定向页面,而不会丢失当前页面的数据。 I found this answer link interesting, particularly his 3rd option, but I am not understanding how to achieve this. 我发现此答案链接很有趣,尤其是他的第三个选择,但我不知道如何实现。 I am using PHP in backend. 我在后端使用PHP。

Since because my pages been loaded according to the hash value change i believe an ajax via is an only solution 因为因为我的页面是根据哈希值的更改加载的,所以我认为通过ajax via是唯一的解决方案

Thanks n advance 谢谢你提前

You can achieve this by storing data either into a session variable array or temp database table. 您可以通过将数据存储到会话变量数组或临时数据库表中来实现此目的。 I would prefer to store it in session. 我希望将其存储在会话中。

If you are doing it using session then it can be: 如果使用会话进行操作,则可以是:

When user clicks on submit, do you check that the user is logged in or not? 用户单击提交时,您是否检查用户是否登录? If yes, then store data into a table. 如果是,则将数据存储到表中。 If not, then store it into a session array, say xyz[] . 如果不是,则将其存储到会话数组中,例如xyz[] After storing it, redirect the user to a login page. 存储后,将用户重定向到登录页面。 After login, you can check if the session array xyz[] contains any value. 登录后,您可以检查会话数组xyz[]包含任何值。 If it does, store it into a particular table and don't forget to unset session array xyz[] . 如果是这样,请将其存储到特定表中,并且不要忘记取消设置会话数组xyz[] Otherwise, redirect user to home . 否则,将用户重定向到home

If you are doing it using the DB then it can be: 如果使用数据库进行操作,则可以是:

When user clicks on submit, do you check that the user is logged in or not? 用户单击提交时,您是否检查用户是否登录? If yes, then store data into db table. 如果是,则将数据存储到db表中。 If not, then store it into a temporary db table . 如果不是,则将其存储到临时db表中 After storing it, redirect user to login page. 存储后,将用户重定向到登录页面。 After login, you can check if the temp db table contains any record. 登录后,您可以检查temp db表是否包含任何记录。 If it does, then move it into a particular table and don't forget to delete record from the temp db table. 如果是这样,则将其移至特定表中,不要忘记从temp db表中删除记录。 Otherwise, redirect user to home . 否则,将用户重定向到home

or else best way 否则最好的方法

In starting of your form just check if user logged in or not? 在开始表单时,只需检查用户是否登录? if not then redirect him to login page. 如果没有,则将他重定向到登录页面。 Otherwise, allow them to fill data in form. 否则,让他们在表格中填写数据。

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

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