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]

JFQ Turnings JFQ Turnings, coming soon.
<?php echo getRandomImage(); function getRandomImage() { $images = array("candlestick.jpg", "rollingpin.jpg", "table.jpg", "table2.jpg"); $random = rand(0, 3); return $images[$random]; } ?> [/code]

Doesn’t look like you have tried anything yet.

Have you looked at the examples in the php manual?
http://php.net/manual/en/features.cookies.php

Sponsor our Newsletter | Privacy Policy | Terms of Service