嗨我有一个php页面,我想只显示一次每个用户。如何显示一个php页面只有一个用户
我认为这可能只是用cookies,session-timeout或session-cookies。
但我不确定。
谢谢你的好意:)
嗨我有一个php页面,我想只显示一次每个用户。如何显示一个php页面只有一个用户
我认为这可能只是用cookies,session-timeout或session-cookies。
但我不确定。
谢谢你的好意:)
你回答了你自己的问题 - 通过设置一个cookie。
// check if they've been here, if they haven't set
// a cookie for subsequent visits
if($_COOKIE['beenhere']) {
setcookie("beenhere", '1');
}
else {
// where you want them to go if they've seen this page
header('Location: http://www.example.com/');
欲了解更多信息:
如果你想单个用户-never-再次看到的页面,你必须设定一个到期的cookie(请参阅上面的链接页面),因为关闭浏览器会消除Cookie,因为我已将它设置在上面。
这很好,我曾经用它。但是,有没有办法让每个用户都拥有这个?我有一个$ _SESSION变量,并且我希望新手用户进来时显示一个页面。一台电脑可以登录多个SESSIONS,所以不能选择cookies。任何帮助? – FoxInFlame 2015-04-26 09:43:30
显示网页一次每用户会话,你可以试试下面的
//mypage.php
if(!isset($_SESSION['mypage_view'])
{
$_SESSION['mypage_view'] = 1;
} else {
//check if this is not the first time the page has been viewed
if(isset($_SESSION['mypage_view'])) {
//not first time redirect
header('location: google.com');
session_write_close();
exit();
}
}
您还可以使用会议
if($_SESSION['sessioned_here'] == null) {
// just been on this page
} else {
// visited already. get out
}
会话创建一个cookie,所以实际上你使用的是cookie – Erik 2011-03-20 08:07:20
每个用户会话一次或一次“永远”? – Andreas 2011-03-20 08:00:51
每个用户,谢谢... – Freeman 2011-03-20 08:01:44
你可以这样做,所以每个IP地址只有1个人可以查看它。 – 2012-03-06 22:45:28