重定向回到引用者

时间:2015-11-25 17:09:06

标签: php wordpress referrer

我正在尝试将引荐来源网址作为变量传递,以便当用户登陆该网页时,如果尚未设置Cookie,则可以链接回该网页。

目前正在调查$_SERVER['HTTP_REFERER']但不太确定如何运作以及如何在下面的函数中传递它。

非常感谢任何帮助。

function cookie_check() {
    $post_ID = get_the_ID();
    $parent_ID = wp_get_post_parent_id( $post_ID );

    if($parent_ID == 9 || $post_ID == 9) {

            if(!isset($_COOKIE["mycookie"])) {
                header("Location: http://test.dev");
                die();
            }
    }
    if($parent_ID == 7 || $post_ID == 7) {
            if(!isset($_COOKIE["diffcookie"])) {
                header("Location: http://test.dev");
                die();
            }
    }
}

0 个答案:

没有答案
相关问题