cookie issue not setting

[php] setcookie(‘lotrd’, ‘’, time()+900); ##-- kills in 15min
if (!isset($_COOKIE[‘lotrd’]))
die(‘no cookie’);[/php]

this will always die. I am writing a game and have been working on the afk. was working find in the first few drafts, now that i cleaned up the code. i cant set a cookie, so i did this debug script on the spot, and it fails.
i tried in 3 different browsers, but it just will not set…

any suggestions where i can start looking?

Your cookie does not have a value…
[php]
setcookie(“Name”, “Value”, expire);
[/php]

give it a value and is should go

sorry forgot to mention with or w/o a vaule - it still fails…

Since the game is 1. Text based, and 2. Small population, and since I could not get the cookie to no longer work, I took this route (somewhat redundant - but good alternative)

[size=12pt]keep in mind this is a kludge:[/size]
[php]function KillDeadBeats() // may use KillDeadBeats($id) on busy servers
{
$sql = "SELECT * FROM player";
$query = mysql_query($sql);

    $limit = time() + 900;                                                 
    while($slacker = mysql_fetch_assoc($query))
    {
        if ( ($slacker['last_on'] + 900) > $limit )                         // fell asleep
        {
            update_record('player','on_now',0,'id',$slacker['id']);
        }
    }
}[/php]

Once it has checked for everyone that has exceeded 15 min, check to see if the current player got bumped
[php]
if(isset($_SESSION[‘userid’]))
{
$u = GetUser($_SESSION[‘userid’]);
if ($u[‘on_now’] == 0)
{
$_REQUEST[‘q’] = ‘afk’;
}

    /** stupid cookie fail
    if(!isset($_COOKIE['lotrd']))
    {
        header('index.php?q=afk');
    }else{
       
        setcookie('lotrd','afk',time()+900);
    }
    */
}
[/php]

and it finally sends them to afk - JUST LIKE the simple cookie method did. As you can see, cookie might have been a better option, but the more I look at this, the more I like this one better. preference I guess

*Note: elsewhere in the program, player is allotted more time, if they are not afk.

anyways. would really like to know why the cookie wont set (did on many of my drafts, but not this draft)

Sponsor our Newsletter | Privacy Policy | Terms of Service