Results 1 to 2 of 2

Thread: running setcookie()

  1. #1
    Join Date
    Feb 2015
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default running setcookie()

    I have a script i was playing with below. I want to edit it using the setcookie() function to set a cookie with the random image script, using the $_COOKIE array, i want to be able to read the cookie if its available. Finally i want to create a test condition where a new random index is selected if the user has previously viewed the image and the cookie is available. I would love to know how to do this, im trying to familiarize myself on doing different scripts.



    Code:
      <html>
      <head>
      <title>JFQ Turnings</title>
      </head>
      <body bgcolor="#ffffff" text="#000000">
      <img src="jfqturnings.gif" alt="JFQ Turnings, coming soon." width="864" height="100">
      <br /><img src="<?php echo getRandomImage(); ?>" alt="" width="864" height="567">
      <?php
      echo getRandomImage();
     function getRandomImage()
     {
     $images = array("candlestick.jpg", "rollingpin.jpg", "table.jpg", "table2.jpg");
     $random = rand(0, 3);
     return $images[$random];
     }
     ?> 
     </body>
     </html>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

Similar Threads

  1. dropdown box value activates a setCookie
    By motormichael12 in forum Other
    Replies: 10
    Last Post: 05-24-2014, 05:03 AM
  2. setcookie before content????
    By jscheuer1 in forum PHP
    Replies: 11
    Last Post: 08-15-2012, 01:14 AM
  3. adobe cs4 is running on a 32-bit PC ?
    By leonidassavvides in forum Computer hardware and software
    Replies: 1
    Last Post: 05-30-2008, 02:07 PM
  4. Replies: 1
    Last Post: 06-28-2007, 02:57 PM
  5. Modify setcookie
    By hnpdyn in forum JavaScript
    Replies: 1
    Last Post: 02-13-2006, 06:26 AM

Bookmarks

Posting Permissions

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