Beginner PHP Tutorial – 75 – Creating Cookies with PHP | VPS and VPN
Web Hosting
Beginner PHP Tutorial - 75 - Creating Cookies with PHP

Beginner PHP Tutorial – 75 – Creating Cookies with PHP

Website –
GitHub –
Reddit –
Twitter –
Facebook –
LinkedIn –
Instagram –


41 thoughts on “Beginner PHP Tutorial – 75 – Creating Cookies with PHP

  1. if you are getting the error Notice: Undefined index: username in C:xampphtdocsnew on line 3
    put the setcookies script in another file and the echo cookie script in another file

    good luck 🙂

  2. Thank you. I love your videos. I have a difficult task though for my FMA i have to submit in 2 weeks. I have to create a form. I have to submit it to another page and if there are errors the same page needs to be redisplayed plus the data that is already valid must exist so the user does not have to repeat.
    Could you do a video on advanced form handling with php without REGEX please???????? Many Thanks in advance

  3. Thanks for these powerful videoes about php. I am using WAMP server but when trying to setcookie
    $time = time();
    it gives an error
    what is the reason for that?

  4. If you would like an easy way to set time in cookies you could paste in this simple function ( ), made by me. This is how you use it:
    timeAdd(3, "d")  This sets time 3 days from now.
    This is how it should be looking in the setcookie:
    setcookie("cookiename", "cookievalue", timeAdd(3, "d"));
    Here's the values you're able to use in the second string:
    "m"  – Minute
    "h"   – Hour
    "d"   – Day
    "W"  – Week
    "M"   – Month
    "Y"   – Year
    The first value requires only a int which will be how many, for example, years the cookie should stay if "Y"-case.
    The function might not always be accurate because some months doesn't always have 31 days.

  5. Damn. I was stuck for a good 15mins trying to figure out why my cookie would not set (was using print_r($_COOKIE); to see all cookies). Turns out I had to use double quote instead of single ones. Makes NO sense. Great consistency php designers. -_-

  6. You cannot create a permanent cookie. However you can create one with a very long experation time.


  7. message 'Notice: Undefined index: username in C:xampphtdocsseriesalex's examplecookieview.php on line 3' will come out if the time is expired,how can i fix this?

  8. I think Bucky should redo this series when he has time, every time I start to try to memorize something, alex goes "ummmm why isn't this working, oh yeah I forgot the most important part,let me just change that at the speed of light and switch screens."

  9. @MrJohnPringle. that is because of the error_reporting setting in your php.ini file. change it accordingly and u shouldn't be getting it anymore.
    put it as error_reporting = E_ALL & ~E_NOTICE

Leave a Reply

Your email address will not be published. Required fields are marked *