最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

session - Retrieve parameter from url

programmeradmin0浏览0评论

Given a certain url, custom = www.namesite/r=namerefferrer

to initialize a $_SESSION and retrieve the value of this $_SESSION I did:

I set this in functions.php:

if (!session_id()) {
    session_start();
    if($_GET['r']){
        $_SESSION['referrer']=$_GET['r'];
    }
}

in my front-page.php;

<?php 
$rp = $_SESSION['referrer'];
echo $rp;
?>

but it does not recover anything unless I modify the url by adding a? after the /, like this:

www.namesite/?r=namerefferrer

how to recover the session and show it without ?

发布评论

评论列表(0)

  1. 暂无评论