| |
|
|
| |
Creating Cookies using PHP
Next Code
How
to Create a Cookie
The setcookie() function is used to create
cookies.
Note: The setcookie() function must appear
BEFORE the <html> tag.
Syntax
setcookie(name, value, expire, path,
domain);
Example
The following example sets a cookie named "uname"
- that expires after ten hours.
<?php
setcookie("uname", $name, time()+36000);
?>
<html>
<body>
<p>
A cookie was set on this page! The cookie
will be active when the client has sent the
cookie back to the server.
</p>
</body>
</html>
---------------------------------------------------------------------
How to Retrieve a Cookie Value
When a cookie is set, PHP uses the cookie
name as a variable.
To access a cookie you just refer to the
cookie name as a variable.
Tip: Use the isset() function to find out if
a cookie has been set.
Example
The following example tests if the uname
cookie has been set, and prints an
appropriate message.
Go
to Homepage
Contact Us
|
|
| |
By Krishna Eydat & Mahmood Bina |
|
Download free PHP codes and scripts, help with
forums, samples and examples of a professional website with PHP
design, you can use Javascript codes and HTML scripts and tangs.
PHP tutorials and lessons step by step, use PHP free script
,script ,source ,code generator ,sample code ,examples ,script
code ,open source, free source ,forms ,code editor ,forum ,array
,function ,website codes ,include ,Web design, webmaster
,protect code , email , PHP forum codes, forum scripts , dynamic
code, PHP helps
|