Results 1 to 3 of 3

Thread: How to set cookies in php

  1. #1
    Join Date
    Oct 2009
    Posts
    4

    How to set cookies in php

    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..

  2. #2
    Join Date
    May 2008
    Posts
    3,316

    Re: How to set cookies in php

    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.

  3. #3
    Join Date
    Apr 2008
    Posts
    2,139

    Re: How to set cookies in php

    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.

Similar Threads

  1. Replies: 10
    Last Post: 07-03-2012, 09:41 AM
  2. After setting cookies to "Never" Safari accepts all cookies anyway
    By Padmasola in forum Technology & Internet
    Replies: 7
    Last Post: 02-03-2012, 10:27 AM
  3. Google cookies does not obeys the cookies in Opera 10.51
    By Wild Kat in forum Technology & Internet
    Replies: 3
    Last Post: 26-02-2012, 01:54 PM
  4. Get rid of cookies on a Mac
    By Erinyes in forum Technology & Internet
    Replies: 5
    Last Post: 02-04-2010, 11:02 AM
  5. What Are The Cookies?
    By Samra in forum Technology & Internet
    Replies: 2
    Last Post: 01-10-2008, 06:23 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,532,011.82690 seconds with 17 queries