Write a php program to store the username in cookie and check whether the user have successfully login or not
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
Solution
Cookies are pieces of content that are sent to a user's web browser. To set a cookie, we must call the setcookie() function before sending any other content to the browser, because a cookie is actually part of the header information.
Syntax of setcookie()
setcookie(name, value, expire, path, domain, secure, httponly);
The following example demonstrates how to store the username in a cookie and check whether that user successfully login or not -
In the above code, we have set a variable to know if we submitted a login or not, and sets the username in cookie.
need an explanation for this answer? contact us directly to get an explanation for this answer