Current Location: Home> Function Categories> setrawcookie

setrawcookie

Send unurl-encoded cookies
Name:setrawcookie
Category:Network
Programming Language:php
One-line Description:Defines the cookie to be sent with the remaining HTTP headers (without URL encoding).

Definition and usage

setrawcookie() function defines a cookie that is not encoded by a URL, which will be sent with other HTTP headers.

Cookies are often used to identify users. A cookie is a small file embedded in the user's computer by the server. Whenever the same computer requests a page through the browser, it sends that cookie. Using PHP, you can create and retrieve cookie values.

The name of the cookie is automatically assigned to the variable with the same name. For example, if a cookie named "user" is sent, a variable named $user is automatically created, which contains the value of the cookie.

Note: setrawcookie() function must appear before the <html> tag.

Note: To automatically URL encode the cookie value when sent and decode it automatically when received, use setcookie() function.

grammar

 setrawcookie ( name , value , expire , path , domain , secure ) ;

Parameter value

parameter describe
name Required. Specify the name of the cookie.
value Optional. Specifies the value of the cookie.
Expire

Optional. Specifies the expiration time of the cookie.

The value time()+86400*30 will set the cookie to expire after 30 days.

If this parameter is not set, the cookie will expire at the end of the session (i.e. when the browser is closed).

path

Optional. Specifies the server path of the cookie.

If set to "/", the cookies are available for the entire domain.

If set to "/php/", cookies are only available for the php directory and all its subdirectories.

The default value is the current directory where the cookie is set.

domain

Optional. Specify the domain name of the cookie.

To make cookies available in all subdomains of example.com, set domain to ".example.com".

Setting it to "www.example.com" will make the cookie available only in the www subdomain.

Secure

Optional. Specifies whether cookies are transmitted only over a secure HTTPS connection.

TRUE means that cookies are set only if a secure connection exists. The default value is FALSE.

Similar Functions
Popular Articles