search
HomeBackend DevelopmentPHP ProblemHow to set php cookie time

How to set php cookie time

Jul 07, 2020 am 09:04 AM
cookie

php Cookie time setting method: First create a sample file; then enter the cookie statement as "setcookie("cookie_name", "abcd", time() 3600);", which means that the cookie has 3600 seconds ;Finally save the file.

How to set php cookie time

php cookie time setting method

setcookie("cookie_name", "abcd", time()+3600);

This means that this cookie has a validity period of 3600 seconds

Definition and usage

The setcookie() function sends an HTTP cookie to the client.

Cookie is a variable sent by the server to the browser. Cookies are typically small text files that a server embeds on a user's computer. This cookie is sent each time the computer requests a page through the browser.

The name of the cookie is specified as a variable of the same name. For example, if the cookie being sent is named "name", a variable named $user is automatically created containing the cookie's value.

The cookie must be assigned before any other output is sent.

If successful, the function returns true, otherwise it returns false.

Parameters

name required. Specifies the name of the cookie.

value Required. Specifies the cookie value.

expire Optional. Specifies the validity period of the cookie.

path Optional. Specifies the server path for cookies.

domain Optional. Specifies the domain name for the cookie.

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

For more related knowledge, please visit PHP Chinese website!

The above is the detailed content of How to set php cookie time. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools