setrawcookie in PHP

setrawcookie in PHP

setrawcookie() is a function in PHP that is used to set a cookie in the user’s browser with the value that has not been URL encoded. The function is similar to the setcookie() function, but it does not encode the value of the cookie.

The function has the same parameters as setcookie():

  • name: the name of the cookie.
  • value: the value of the cookie.
  • expires: the expiration time of the cookie in Unix timestamp format. If not set, the cookie will expire when the browser is closed.
  • path: the path on the server where the cookie will be available.
  • domain: the domain where the cookie will be available.
  • secure: indicates whether the cookie should only be transmitted over a secure HTTPS connection.
  • httponly: indicates whether the cookie should only be accessible through HTTP requests, and not through client-side scripting languages like JavaScript.

Here’s an example of setting a raw cookie in PHP:

// Set a raw cookie with the name "username" and value "john+doe"
setrawcookie("username", "john+doe", time() + 3600, "/");

Apply for PHP Certification!

https://www.vskills.in/certification/certified-php-developer

Back to Tutorials

Share this post
[social_warfare]
setcookie in PHP
Understanding Templated Controls

Get industry recognized certification – Contact us

keyboard_arrow_up