Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What is PHP Cookie and how to create it

Shulou Source: shulou.com Published: 2022-05-31 13:50:16 09月24日 Update

Most people do not understand the knowledge of this article "what PHP Cookie is and how to create it", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "what is PHP Cookie and how to create" article.

Cookie is often used to identify users.

What is Cookie?

Cookie is often used to identify users. Cookie is a small file that the server leaves on the user's computer. Whenever the same computer requests a page through a browser, this computer will send a cookie. With PHP, you can create and retrieve the value of cookie.

How do I create a Cookie?

The setcookie () function is used to set the cookie.

Note: the setcookie () function must precede the tag.

Syntax setcookie (name, value, expire, path, domain); example 1

In the following example, we will create a cookie named "user" and assign it a value of "runoob". We also stipulate that this cookie expires in an hour:

.

Note: when sending cookie, the value of cookie is automatically URL encoded and automatically decoded when retrieved. To prevent URL coding, use setrawcookie () instead. )

The above is about the content of this article on "what PHP Cookie is and how to create it". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Tags: Content users functions articles comments knowledge articles coding computers instead values examples most examples hours that is files more servers tags Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Redmi vpn Huawei Linux