I have too much information about cookies but the thing that i dont know is, how to set cookies in php? i tried to set cookies from my side but nothing works at all, can any one help me to set the cookies..
I have too much information about cookies but the thing that i dont know is, how to set cookies in php? i tried to set cookies from my side but nothing works at all, can any one help me to set the cookies..
Cookies are directly sent( by the script ) to the browser before your page is sent,in the HTTP headers. If you want to set the cookies, they must be set before you send a single line of HTML or any other output. To set cookies you should try, the setcookie() function. If a setcookie function returns a FALSE value, the cookie will not be sent and you will get a PHP error message. If a setcookie() function returns a TRUE value, the cookie is successfully sent to the web browser (the cookie has been set).
Last edited by Raine; 13-11-2009 at 11:24 AM.
For setting cookies in php you can use the following syntax:
setcookie(name,value,expire,path,domain,secure)
In the above syntax, the terms that are enclosed in brackets are the parameters. By using all those parameters you can set a cookie. Here, the name parameter specfies the name of the cookie, value specifies the value of the cookie, expire parameter is optional, domain specifies the domain name of the cookie, secure parameter specifies whether the cookie should only be transmitted over a secure HTTPS connection or not. If the value is TRUE, the cookie will only be set, if a secure connection exists. Otherwise default is FALSE.
Bookmarks