Results 1 to 4 of 4
  1. #1

    hojkoff_101's Avatar
    Member Since
    Oct 18, 2005
    Location
    Edinburgh Scotland
    Posts
    225
    Specs:
    Macbook 2.1GHz Intel Core 2 Duo, 4Gb RAM
    Cookie php code not working!
    Can someone tell me why this won't work? I can't understand why it won't install a cookie on my browser! I've tried Safari, Firefox and Opera and no luck on any of them!

    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Cookie</title>
    </head>

    <body>

    <?php 

        setcookie
    ("test"45time()+(3600));
        echo 
    "This page has loaded correctly! But is thy cookie there!";
        
    ?>
    <br />
    <a href="cookie_read.php">Check that cookie!</a>
    </body>
    </html>
    The link is to a page which has been coded to show the value of the cookie but it doesn't display any value! When I check the cookies stored on my browser it isn't there either!

    Any ideas as to why it's all going wrong!!!!!

    Thanks guys!


    Andy

  2. #2


    Member Since
    Feb 15, 2012
    Posts
    3
    Same with me. And safari 4.0.3 does not support PHP

  3. #3

    Groovetube's Avatar
    Member Since
    Nov 15, 2011
    Location
    Toronto
    Posts
    288
    Specs:
    Retina MBP 2.7 768ssd/16gig ram /30" dell 3008. and bunch of other mac/apple stuff
    you need to out the setcookie call above output or any html tags, whitespace etc. much the same kind of issues can affect this call like the header calls. It's sent with the html headers.

    Take that setcookie line and put it up above everything, no whitespace.

    ie:
    PHP Code:
    <?php setcookie("test"45time()+3600); ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Cookie</title>
    </head>

    <body>
    This page has loaded correctly! But is thy cookie there!
        <br />
    <a href="cookie_read.php">Check that cookie!</a>
    </body>
    </html>

  4. #4

    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,742
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    Quote Originally Posted by BrandonSkyPim View Post
    Same with me. And safari 4.0.3 does not support PHP
    Every browser "supports" PHP since it doesn't actually interact with PHP. PHP is a server side technology - all the heavy lifting is done on the server. It works by interpreting the code and returning the corresponding HTML. For instance, let's take the following PHP code:
    Code:
    echo "<div id='test'>Hello</div>";
    When the page with that code is requested, the PHP interpreter is called on the server, it figures out that you want to echo out a div with some text and sends the following to your browser:
    Code:
    <div id='test'>Hello</div>
    Important Links: Community Guidelines : Use the reputation system if you've been helped.
    M-F Blog :: Write for the blog
    Writing a Quality Post

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Cookie problem
    By max1baer in forum OS X - Operating System
    Replies: 2
    Last Post: 08-17-2011, 02:07 AM
  2. PHP is not working on Leopard/Apache2.2--Help!
    By riceric in forum Web Design and Hosting
    Replies: 0
    Last Post: 05-02-2009, 02:38 PM
  3. Setting up PHP and PHP Nuke
    By EvoMac in forum Web Design and Hosting
    Replies: 2
    Last Post: 02-18-2005, 01:38 PM
  4. Replies: 3
    Last Post: 07-02-2004, 10:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •