Beginner PHP Tutorial – 75 – Creating Cookies with PHP
Website –
GitHub –
Reddit –
Twitter –
Facebook –
LinkedIn –
Instagram –
source
Cookies is not good for login
Rather sessions
How to make cookie logger
Please let me know if anyone knows that how many cookies and sessions can be created in a website using PHP Technology?
75 down
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 🙂
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
Sir how can set cookies for other browse
HTML5 cookies better than PHP ??
Killing a Cookinbird.
Thank you very much
It works with using time(). But when the cookie expires it shows Undefined index.
What do I do if I accidentally ate the cookie? Need help
Thanks for these powerful videoes about php. I am using WAMP server but when trying to setcookie
session_start();
$time = time();
setcookie('username','something',$time+10);
it gives an error
what is the reason for that?
you deLiver SIR a good concept in very concise way. U Do weLL job
What if i want a permanent cookie?
Notice: Undefined index: username in C:xampphtdocsnew on line 3
help me
Wow. The day when someone explains to me what a cookie is /:
Cookie seems not to be that mysterious now 🙂
I thought all time in programming languages are set from 1st January 1970, dunno why you thought 1990s lol. Great tutorials though
Would you really use cookies for login purposes nowadays?
So what would happen if you cleared cookies in your browser before the 10 seconds was up? It wouldn't display 'username', right?
I love how you say cookies. "Cukys"
If you would like an easy way to set time in cookies you could paste in this simple function ( http://pastebin.com/T6hSgrC6 ), 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.
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. -_-
I like cookies, especially with chocolate chips on top.
You cannot create a permanent cookie. However you can create one with a very long experation time.
stackoverflow(dot)com/questions/6865259/php-permanent-cookie
Why don't you make the cookie expire when the user logs out (i.e. session destroyed)?
pretty damn good idea you got there
eat your cookies before they expire
Rofl, nothing is working! xD
ThaNK YOUUUU ALeX
okok just realized…
Ey. Thanks Alex, but I'm wondering: I didn't get how you get to the 'parent directory' page??
i use netbeans IDE 7.2
Maybe you didnt name your cockie corectly?
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?
@LaughingShinoo naoooooooooooooooooooooooooooooooooooooooooooaaaaaaaaaaoooooooooooooooaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@LaughingShinoo The only thing stopping you is your attitude. If you need help beyond these videos, send just ask in a reply to my posts.
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."
PROGRAMMIN IS FUN!
@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