+ 2
Hey! I want to use cookies,but when I used it didn't work can anyone help me
3 Respuestas
+ 6
Sure! I reviewed your code, and it looks like there is a small mistake in the way you are setting the cookie expiration time.
Currently, you are using the time() function to set the cookie expiration time to one hour from the current time:
setcookie("user_input", $user_input, time()+3600);
However, this will cause the cookie to expire exactly one hour after it is set, regardless of when the user initially accessed the page. To set the cookie to expire one hour after the user initially accessed the page, you can use the following code:
setcookie("user_input", $user_input, time()+3600, "/");
+ 6
This sets the cookie expiration time to one hour after the current time, but also includes the optional fourth parameter of the setcookie() function, which sets the cookie path to the root directory (/). This ensures that the cookie is available to all pages on your site, not just the current directory.
With this change, your code should work correctly and remember the user input for one hour after the user initially accessed the page.
0
Sadaam Linux actually its not storing data(cookies