iNET Interactive - Online Advertising Agency
          
   Home    Authors    About    Login    Contact Us
   Search:   
Advanced Search     
  Articles

  ASP (26)
  ASP.NET (19)
  C and C++ (4)
  CFML (2)
  CGI and Perl (16)
  Flash (2)
  Java (7)
  JavaScript (28)
  PHP (92)
  MySQL (13)
  MSSQL (3)
  HTML (35)
  SEO (9)
  Visual Basic (12)
  CSS (13)
  SSI (5)
  XML (12)
  C# (14)

  Developer News

July 3, 2008
Poll: Which Web editor do you use?
About
 
July 3, 2008
Book Review: Head First JavaScript
WebReference.com
 
July 3, 2008
10 Things You Can Do With a Wiki
About
 
July 2, 2008
Web Host Reviews - 10 New Reviews
About
 
July 2, 2008
14 Reasons You Should Join a Social Network
About
 
July 1, 2008
Mark Boulton's Freelance Design Secrets
SitePoint
 
Courtesy of moreover.com
 
Want to receive new articles via e-mail? Click here!
/Home /PHP /Cookies and Sessions

PHP's Cookie handeling functions 

  Views:    18378
  Votes:    0
by Martyn Coupland 5/06/04 Rating: 

Synopsis:

Get to grips with the basics of PHP's Cookie handeling functions with this tutorial.
Pages: firstback1 forwardlast
The Article

Setting Cookies

As explained on the previous page, the setcookie() function has many attributes. However only one is required, this is the name attribute.

<?php setcookie("CookieName"); ?>

The code above will set a cookie with the name CookieName, all cookies in PHP can be accessed using the $_COOKIE array. The syntax for this is as follows...

$_COOKIE['name']

You would replace name with the name of the cookie, so for our first example this would be CookieName, then you would use the echo function to print out the value...

<?php echo "{$_COOKIE['CookieName']}"; ?>

Remember: If you are using double quotes to echo things out, remember to place {} around anything which contains single quotes or PHP will generate an error.

This concludes our very basic introduction to PHP's cookie function setcookie(). You can find more information and examples on the PHP Manual.

Pages: firstback1 forwardlast

Similar/related articles:


 
  Sponsors