Forgot your password?



 

Why sign up?
- One account for five websites!
- Free access to Premium Codes
- Acess to cool web tools
- Ask and answer questions
- Stay ahead of other web developers
- and MUCH MORE!

 





Feel The Power

webPhp Code: Creating Cookies using PHP


How to Create a Cookie
The setcookie() function is used to create cookies.

Note: The setcookie() function must appear BEFORE the tag.

Syntax
setcookie(name, value, expire, path, domain);


Example
The following example sets a cookie named "uname" - that expires after ten hours.

setcookie("uname", $name, time()+36000);
?>



A cookie was set on this page! The cookie will be active when the client has sent the cookie back to the server.





---------------------------------------------------------------------

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.

If you don't know how to use this code or need more information Click here!

Go to Homepage


 

You can leave comments once you sign in/up.


Review

Please Rate this!

Visitor

Onlines:
Total Online:
Recent Members: scienceguyz, mihir5555, sibekatea, evildead, OLFU_Cate_Imba