php缓存错误
我的控制面板用户中有一个页面,需要密码才能 使用权。
我执行此操作的顺序是:
- 使用我想要访问的页面参数转到“秘密代码请求页面”。
- 检查密码,如果正确,则使用“哈希页面名称”填充会话变量,
- 重定向到我想要访问的页面。
- 此页面检查“哈希会话”是否与此“页面名称”匹配,
- 如果匹配,则清除会话并显示整个页面,如果不匹配,则重定向到初始页面。
问题是:在第 4 步,页面有时会读取较晚的会话 更新。有时它没有显示任何价值,但很多时候它显示了 正确的值,如果我刷新页面,会话仍然有 正确的散列数据(在第 5 步,如果匹配,我已经清除会话 变量),怎么办?
我尝试用mysql的数据记录更改会话变量,但是 我得到了同样的结果。 phpmyadmin 显示已设置记录,但是 页面显示没有数据集。否则,删除记录后, 页面仍显示之前的记录值。
这是否意味着缓存有问题?我也做了标题没有缓存 例如:
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
但我得到的结果仍然相同。大家有什么建议吗?
更新:如果我不断刷新页面,可能刷新 3 或 5 次后,它会显示正确的值。如何使其实时?那么如果会话设置了,页面可以直接检查设置的值,如果会话清除,那么页面会询问密码。
I have single page in my control panel user which need secret code to
access.
My sequence for doing this are :
- go to "secret code request page" with a parameter which page i want to access.
- check the secret code, if correct then fill the session variable with "hashed page name"
- redirect to page i want to access.
- this page check the "hashed session" whether match or not with this "page name"
- if match, clear the session and show the entire page, if mismatch then redirect to initial page.
The problem is : at step 4, the page sometimes read the late session
update. sometimes it shows no value, but many times it shows the
correct value and if I refresh the page, the session still have
correct hashed data (at step 5, if match, i already clear the session
variable), howcome?
i try to change the session variable with data record with mysql, but
i got same result. the phpmyadmin shows the record already set, but
the page shows no data set. and otherwise, after record deleted, the
page still shows the previous record value.
is this means a problem with the cache? i also did the header no cache
such as :
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
but still same result i got. any suggestion guys?
updates : If i keep refreshing the page, after maybe 3 or 5 refreshed, it shows the correct value. how to make it realtime? so then if the session set, the page can directly check the value set, and if the session cleared, so the page will ask the secret code.?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
转储第 4 步中的会话: print_r($_SESSION) 以查看它是否已设置。如果没有,您需要在进行重定向之前在第 2 步中进行设置。
另外不要忘记对每个文件调用 session_start() 。
dump out the session in step 4: print_r($_SESSION) to see if it's set or not. If not, you need to set it in Step 2 before you make the redirect.
Also don't forget to call session_start() on every file.