Wednesday, 23 May 2012
 Home arrow Blog arrow PHP: Set or create a simple browser cookie with setcookie
   
Main Menu
Home
News
Blog
Links
Search
FAQs
Spider
Articles
@intrenet
Free Softwares
Break for fun
Friends VIdeos
Techno videos
Contact Us
Disclaimer
Guest Book
Speed test
V.E.C. Calculator
IPv4 Subnet Calc
IPv6 Subnet Calc
Byte Converter
Converter
GMT/UTC Time
Bandwidth Calc
Allinone Calc
IANA Port Numbers
Country Call Codes
Pk Postal Codes
Surf Anonumously
Visitors Counter
mod_vvisit_countermod_vvisit_countermod_vvisit_countermod_vvisit_countermod_vvisit_countermod_vvisit_countermod_vvisit_counter
mod_vvisit_counterToday204
mod_vvisit_counterYesterday260
mod_vvisit_counterThis week464
mod_vvisit_counterThis month5013
mod_vvisit_counterAll125689
 
 
 
 


PHP: Set or create a simple browser cookie with setcookie PDF Print E-mail
User Rating: / 0
PoorBest 
Written by Amanatullah khalil   
Sunday, 24 May 2009

PHP: Set or create a simple browser cookie with setcookie

 

Web applications overcome the lack of session support in the HTTP protocol primarily through the use of cookies. Transparent to the user and simple for the web developer, cookies provide the foundation of keeping up with who a web user is, where they’ve been, and what they had for lunch. Well, who and where, anyway.


The built-in PHP function setcookie() creates or updates a cookie name/value pair in the user’s browser. A cookie contains information sent by a web server to a user’s browser. Whenever a web page is accessed at that server that meets the requirements, cookies associated with that server (that haven’t expired) are sent back without modification to the server.

The basic cookie consists of a name and a value. For example, a cookie with name ‘user’ can be set to the user’s username, possibly encoded for security. To set the cookie user with the value ‘qmchenry’ use this command:

setcookie('user','qmchenry');

This cookie has a default expiration time of 0 which means it will persist until the browser is closed.

It is important to note that cookie information is sent in the web page response headers and, like other times PHP needs to change header values, the setcookie function must be called before any output is sent to the user.

courtesy http://www.tech-recipes.com/rx/1499/php-set-or-create-a-simple-browser-cookie-with-setcookie/

 
< Prev   Next >
 
 
 
csatpk Newsflash
Statistics
OS: Linux h
PHP: 5.2.17
MySQL: 5.1.63-community-log
Time: 04:01
Caching: Disabled
GZIP: Disabled
Members: 3
News: 368
Web Links: 5
Visitors: 266049
Popular