好吧,我会尽量保持这个简单和甜蜜。我正在开发我的网站,当用户首次加载网站时,它当前会加载启动页面。这就是我想要的行为。
- 如果用户以前从未访问过该站点,则重定向到启动页面。
- 如果用户之前访问过该站点并且不想看到启动画面,请不要重定向。
- 如果用户喜欢启动画面并希望在新会话中看到,则显示启动画面。
那些基本上是我正在使用的场景,真的想不出更多了,在过去的几个小时里一直试图破解一些东西,但没有运气。
索引.php
<?php
setcookie("visit", "true", mktime (0, 0, 0, 12, 31, 2014), "/"); // delete cookie on 31DEC14
$cookie_splash = $_COOKIE['splash'];
$cookie_visit = $_COOKIE['visit'];
$cookie_visit_now = $_COOKIE['visit_now'];
do {
if ($cookie_splash == '' && $cookie_visit == '' && $cookie_visit_now == '') {
/*
echo "<script type = text/javascript>";
echo "window.location = 'http://chrisrjones.com/splash.php'";
echo "</script>";
*/
header('Location: splash.php');
}
if ( $cookie_splash == 'false' && $cookie_visit_now == 'true') {
break;
}
if ( $cookie_splash == 'true' && $cookie_visit_now == 'false') {
/*
echo "<script type = text/javascript>";
echo "window.location = 'http://chrisrjones.com/splash.php'";
echo "</script>";
*/
header('Location: splash.php');
}
if ( $cookie_splash == 'true' && $cookie_visit == 'true' && $cookie_visit_now == "false") {
/*
echo "<script type = text/javascript>";
echo "window.location = 'http://chrisrjones.com/splash.php'";
echo "</script>";
*/
header('Location: splash.php');
}
if ($cookie_splash == 'true' && $cookie_visit == 'true' && $cookie_visit_now == 'true') {
break;
}
}
while (0);
?>
飞溅.php
<p>
<form name="tosplashornottosplash" action="scripts/splash-process.php" method="post" onSubmit="return valForm()">
Splash pages are stupid.
<input type="radio" name="splash" id="splash_false" value="false" /> No
<input type="radio" name="splash" id="splash_true" value="true" /> Yes
<input type="submit" name="splashSubmit" onClick="return valForm(tosplashornottosplash)" value="Enter" />
</form>
</p>
飞溅过程.php
<?php
setcookie("visit", "true", mktime (0, 0, 0, 12, 31, 2014), "/"); // delete cookie on 31DEC14
setcookie("visit_now", "true", NULL, '/'); // cookie should expire / delete at end of session.
$splashvar = $_POST["splash"];
if ( $splashvar == "false" ) {
// create cookie - splash 1
setcookie("splash", "true", time()+3600, '/'); // expires in one hour
}
else {
// create cookie - splash 0
setcookie("splash", "false", time()+3600, '/'); // expires in one hour
}
echo "<script type = text/javascript>";
echo "window.location = 'http://chrisrjones.com/index.php'";
echo "</script>";
?>
去 chrisrjones.com 看看我在说什么。