English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Основной Уроки

PHP Уровень продвинутый Уроки

PHP & MySQL

PHP Референс Мануал

Пример использования функции PHP setrawcookie()

    PHP HTTP  reference manual

Функция setrawcookie() отправляет cookie без URL-кодирования.

Синтаксис

bool setrawcookie ( string $name [, string $value [, int $expire = 0 [, string $path [, string $domain [, bool $secure = false [, bool $httponly = false ]]]]]]] )

Definition and usage

 setrawcookie() and setcookie() are very similar, the only difference is that the cookie value sent to the browser is not automatically URL-encoded (urlencode).

Return value

Returns true if successful, otherwise returns false

Parameter

Serial numberParameters and descriptions
1

name

The name of the cookie.

2

value

The Cookie value. This value is stored on the user's computer, do not store sensitive information. For example, if the name is 'cookiename', its value can be obtained through $_COOKIE['cookiename'].

3

errno

It contains information about the cookie input.

4

expire

The expiration time of the Cookie. This is a Unix timestamp, which is the number of seconds since the Unix epoch (Greenwich Mean Time, January 1, 1970, 00:00:00). That is, it can be basically the result of the time() function plus the number of seconds you want the Cookie to expire. Or you can use mktime(). time()+60*60*24*30 sets the Cookie to expire 30 days later. If set to zero or omitted, the Cookie will expire at the end of the session (that is, when the browser is closed).

5

path

The server path where the Cookie is valid. Setting it to '/' makes the Cookie valid for the entire domain 'domain'. If set to '/foo/', the Cookie is only valid for the '/foo/' directory and its subdirectories (for example, /foo/bar/). The default value is the current directory at the time the Cookie is set.

6

domain

The effective domain/subdomain of the Cookie. Setting it as a subdomain (for example, 'www.example.com') will make the Cookie valid for this subdomain and its third-level domains (for example, w2.www.example.com). To make the Cookie valid for the entire domain (including all its subdomains), just set it as the domain (in this example, 'example.com').

Online example

Try the following example

<?php
   setrawcookie('cookie_name', rawurlencode($value), time()+60*60*24*365); 
?>

PHP HTTP  reference manual