为什么我的cookie没有设置好

Im trying test the cookie that are set in my browser, earlier cookieid was given inside the url(mydomain.com?cookieid=1234). now im trying to set a cookie by calling the script which sets it. when i load the script known as proceed.php, i want that to go on and set the cookie as i have written. but it does not set the cookie as i intend

proceed.php

<?php

$cookieid = 1234;
include('bin/setcookie.php');

?>

setcookie.php

<?php
include_once dirname(__FILE__).'/../Lodread.php';

    $cookieid = isset($_REQUEST["cookieid"]) ? floatval($_REQUEST["cookieid"]) : 0;
    $project_id = isset($_REQUEST["projectid"]) ? intval($_REQUEST["projectid"]) : 0;
    if (isset($_SERVER['HTTP_REFERER'])){
        $urlParts=parse_url($_SERVER['HTTP_REFERER']);
        if (isset($urlParts['query'])){
            $vars = parse_str($urlParts['query']);
            if (isset($vars['cookieid']) && floatval($vars['cookieid']) > 0 ){
                $cookieid = floatval($vars['cookieid']);
            }
        }
    }         
    if ($cookieid) {
        if ( ! isset($_COOKIE["cid"])){
            $cid = ($project_id?"$project_id:$cookieid":$cookieid);
            setcookie("cid", $cid, time() + 60 * 60 * 24 * 365, "/", ".mydomain.com");
            header('Location: '.Config_Reader::readProjectConfig('Cookie')->base_url.'/set2.php');
        }
    }
?>

This is sample, try like this.

How to Get the Contents of a Cookie:

Cookies set for a page can be retrieved from the variable $_COOKIE['cookie_name'] where 'cookie_name' is the name of the cookie you set earlier.

For example, if you wanted to display the value of the "userlogin" cookie, the following code should do the trick.

echo "Welcome back to the site" . $_COOKIE['userlogin'] ;

Note that you cannot set a cookie in PHP and hope to retrieve the cookie immediately in that same script session. Take the following non-working PHP code as an example:

/* WARNING: THIS WILL NOT WORK */
setcookie ( "userlogin", "anonymous", time()+60 );
echo "Value of userlogin: " . $_COOKIE['userlogin'] ;

Try it without specifying the domain when using the setcookie function. Also, I would recommend passing $cid directly to your header function since the cookie value can't be retrieved within the same php script right away. Then finally you can see if the cookie is set for future use by using $_COOKIE['cookie_name'] in a separate php script to get the cookie's value.

Set Cookie without "mydomain.com". use this:

setcookie("cid", $cid, time() + 60 * 60 * 24 * 365, "/");

now you check cookie set.