1. The only way to delete a cookie is set the expire time in the past. such as time()-3600 etc. Am I right?

  2. But if the the client time zone is behind you, so you want to set the time()-3600*24 to solve the time zone problem. Am I right?

  3. But just in case, some people's computer's clock is set deadly wrong, such as if his computer clock is in 1980 or something, then what?

How do I set up the cookie expired at 1980 for example. Or what is the earlest time to I can set my cookie to be expired?

4.

Will it be best to delete cookie this way, set the value to null and set the time to 0 (so when the session is over the cookie will be deleted.)

setcookie("mycookie", "", 0, "/");

due to if the time is 0, that means after the client close his browser end the the session, this cookie will for sure be deleted?

    don't worry about that

    just delete your cookies with this:

    setcookie ("TestCookie", "", time() - 3600);

    that's it no metter the time this will take the cookie from the user pc and will delete the cookie no matter if his clock is set in 1420 the cookie still will be deleted

      setcookie ("TestCookie", "", time() - 3600);

      this only set the cookie value to "" but physically the cookie is still there, right?

      Such as it will not help to reduce the cookie number (20 cookies per domain allowed) etc.

      Right?

        to be honest I'm not sure about that but..

        10 cookies is a lot for a domain you can store a lot of info in one single cookie, a good website can survive with no more than 3 or 4 cookies 😉

          If like you said the php has changed and the comments in php.net about the client timezone and clock doesn't apply. I think it will delete the cookie (phyiscally) and it will reduce the cookie number.

          Yes, 3-4 cookies will be enough. But if we have the sections such as dealers section, affiliates section, clients section etc. then the cookie numbers are up.

          Plus if we install the third party software such as gallery, forum ... the cookie number will be up too (and worst of all, we don't know how many cookies they use in the third party software.)

          So the cookie number could reach to 20 easily in some projects like that.

          So I am trying to use as less number cookies as I can. Such as use array (or use the cookile and serialize as floodboy suggest.) and I also want to make sure that the cookie will be expired when it is not needed.

          How do you guys handle these issues?

            What I do is to combine the cookies of my forum with my website so if you login in my website you're also logged in my forum too.

            i usually the only premade script that use is my forum all the other scripts that I have are mine, and I have only 4 cookies in my site, that let me do every think that I want 😃

            and the way that I delete cookies is always the same

            setcookie ("TestCookie", "", time() - 3600);

            😉

              Write a Reply...