Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Why aren’t my cookies working?

  • This topic is empty.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #26411
    limonkhan
    Member

    Why aren’t my cookies working?

    PHP cookies are a relatively simple way of tracking users by storing information in their browser. Here are the most common reasons a cookie isn’t working.

    Answer: If your cookies aren’t being set, one very common problem is that something is being sent to the browser before the cookie. The cookies need to be in the header and come before any HTML. For example:

    *insert stupid spam footer link*

    #65273
    Rob MacKay
    Participant

    Well you have to remember that they don’t harden in the oven, you have to take them out and they harden when they cool down.

    Nom nom nom!

    All hail clever-ish spam

    #65479

    CAN I HAZ COOKIE TOO?

    But they shouldn’t harden Rob – they should remain all gooey and yummy inside :)

    #65484
    Rob MacKay
    Participant
    "davesgonebananas" wrote:
    CAN I HAZ COOKIE TOO?

    But they shouldn’t harden Rob – they should remain all gooey and yummy inside :)

    very true – soft enough to melt in the mouth, hard enough to hold… maybe the word should be "set" instead of harden…

    #65493

    We should maybe start our own forums on how to get the ‘perfect’ cookie?

    Hehe

    #65516
    Rob MacKay
    Participant

    Bananacookies.com lol

    #65523

    The Cheeky Monkeys want $1200 for that domain! PFfft!

    #65564
    Rob MacKay
    Participant

    damn them!!!

    #66345
    alex001
    Participant

    If your cookies aren’t being set, one very common problem is that something is being sent to the browser before the cookie. The cookies need to be in the header and come before any HTML. For example:

    <html>
    <head>
    <title>My Page</title>
    <?php
    $Month = 2592000 + time();
    setcookie(AboutVisit, date("F jS – g:i a"), $Month);
    ?>

    This code won’t work, because you are sending the data (the <html> and other tags) to the browser before the cookie. Instead you should use something like this:

    <?php
    $Month = 2592000 + time();
    setcookie(AboutVisit, date("F jS – g:i a"), $Month);
    ?>
    <html>
    <head>
    <title>My Page</title>

    If the problem is that the cookies work for most users but some users are having problems with them, it may be that those particular users have cookies disabled in their browsers. This is not a problem with your code at all, just a user’s personal preference

    #66381
    Rob MacKay
    Participant

    Best spam post yet! Almost on topic to the spam post that started the thread! awesome. Footer link removed.

Viewing 10 posts - 1 through 10 (of 10 total)
  • The forum ‘Back End’ is closed to new topics and replies.