【发布时间】:2013-03-19 06:41:54
【问题描述】:
我在下面有这个网站,我正在玩一些 Wordpress 和 php cookie。 http://johnnylai.me/lotus
我想要做的是,当用户第一次进来时,我希望他们在首页的两个链接中选择一个(这是一个单独的 WP 安装)。下次同一用户返回该站点时,我不希望他们再看到首页(b 4 cookie 已删除或过期),我希望他们直接访问两个站点之一 - http://johnnylai.me/lotus/virksonhed 或 @ 987654323@ - 取决于第一次点击的内容。
我知道我需要一些 cookie 的东西,但我不确定将文件放在哪里以及如何正确放置。
我正在考虑在 WP 安装中名为 function.php 的文件中的 sulition/php 代码,该文件具有首页(http://johnnylai.me/lotus),但不知道这是否是正确的方法。
一些代码示例会很好:)
如有任何帮助,谢谢!
<?php
$expire=time()+60*60*24*30;
setcookie("cat", "/cat1", $expire);
// But this is something with categoies in WP, that's not what i need.
?>
还有
<?php
function has_auth_cookie()
{
// See if cookie is set
if(isset($_COOKIE['lotus'])){
// Do nothing
header('Location: johnnylai.me/lotus/???');
}
else
{
// Do Something else
header('Location: johnnylai.me/lotus/');
}
}
add_action('http://johnnylai.me/lotus/????', 'has_auth_cookie');
?>
【问题讨论】: