[英]Storing HTML 5 LocalStorage using PHP serverside
I've created an account verification system where a user clicks a link in their emailbox which will trigger activate.php, a script which will do some stuff backend in a MySQL db and then present the user with their account. 我创建了一个帐户验证系统,其中用户单击其电子邮件框中的链接,这将触发activate.php,这是一个脚本,它将在MySQL数据库中做一些后端操作,然后向用户提供其帐户。 Currently, I'm doing this with a header change:
目前,我正在通过更改标头来执行此操作:
header( www.mydomain.com/useraccount.html);
The problem: I need certain local storage variable to be set, such as sessionStorage.email and sessionStorage.accountID. 问题:我需要设置某些本地存储变量,例如sessionStorage.email和sessionStorage.accountID。 I can't be sure that these things are currently set because the user could have closed their browser, clicked activate.php after 20 min.
我不确定当前是否已设置这些设置,因为用户可能已经关闭了浏览器,请在20分钟后单击activate.php。 and opened a new session.
并打开了一个新会话。 Therefore I'm wondering how to set HTML 5 local storage variables using PHP.
因此,我想知道如何使用PHP设置HTML 5本地存储变量。 Is this possible?
这可能吗? Thanks in advance!
提前致谢!
Ending up using URL params: header(www.mydomain.com/useraccount.html/usertag=blah&email=blah@gmail.com);
最后使用URL参数:
header(www.mydomain.com/useraccount.html/usertag=blah&email=blah@gmail.com);
and capturing them in Javascript upon page load. 并在页面加载时用Javascript捕获它们。
Embed the JavaScript code to set the localstorage into the page that your activate.php
sends to the client. 将JavaScript代码嵌入以将localstorage设置为您的
activate.php
发送给客户端的页面。 This could be a short dummy piece of html that runs that JavaScript logic and then does a clientside redirect to useraccount.html
. 这可能是一段简短的html虚拟片段,它运行JavaScript逻辑,然后在客户端重定向到
useraccount.html
。
Make sure you provide a fallback if javascript is disabled (ie an explicit link). 如果禁用了javascript(例如,显式链接),请确保提供备用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.