用setCookie()时,将域名指定称“localhost”就保存不了Cookie咋回事?
用setCookie()时,将域名指定称“localhost”就保存不了Cookie怎么回事??
在本地测试的时候发现的。
这样可以设置Cookie:
- PHP code
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> setCookie('name[1]', 'yy1', time() + 3600, '/'); setCookie('name[2]', 'yy2', time() + 3600, '/');
这样就不行了:
- PHP code
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> setCookie('name[1]', 'yy1', time() + 3600, '/', 'localhost'); setCookie('name[2]', 'yy2', time() + 3600, '/', 'localhost');
这是为什么?设置称“localhost”不对吗???
谢谢!
------解决方案--------------------
when working on localhost the cookie-domain must be set to "" or NULL or FALSE
------解决方案--------------------

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The reasons why mysql cannot connect to localhost are that the mysql service is not started, the mysql port is occupied, and there is a problem with the MySQL configuration file. Detailed introduction: 1. In Windows systems, you can open the service manager by entering "services.msc" at the command prompt, then find the mysql service and ensure that its status is "Running". In Linux systems, you can use the "services.msc" command to check and control the service status; 2. You can use the open command and so on.

Cookies are usually stored in the cookie folder of the browser. Cookie files in the browser are usually stored in binary or SQLite format. If you open the cookie file directly, you may see some garbled or unreadable content, so it is best to use Use the cookie management interface provided by your browser to view and manage cookies.

Cookies on your computer are stored in specific locations on your browser, depending on the browser and operating system used: 1. Google Chrome, stored in C:\Users\YourUsername\AppData\Local\Google\Chrome\User Data\Default \Cookies etc.

Solution: 1. Check the running status of the server and make sure it is listening on the correct port; 2. Try to temporarily disable the firewall or security software, and then try to access localhost again; 3. Check the hosts file of the operating system to ensure that localhost is resolved correctly ; 4. Try to restart the network adapter or reconfigure the network connection; 5. Try to change the port used by the local server, or close other programs that occupy the same port; 6. Try to manually add the corresponding IP address and domain name in the hosts file, etc.

Cookies on the mobile phone are stored in the browser application of the mobile device: 1. On iOS devices, Cookies are stored in Settings -> Safari -> Advanced -> Website Data of the Safari browser; 2. On Android devices, Cookies Stored in Settings -> Site settings -> Cookies of Chrome browser, etc.

The dangers of cookie leakage include theft of personal identity information, tracking of personal online behavior, and account theft. Detailed introduction: 1. Personal identity information is stolen, such as name, email address, phone number, etc. This information may be used by criminals to carry out identity theft, fraud and other illegal activities; 2. Personal online behavior is tracked and analyzed through cookies With the data in the account, criminals can learn about the user's browsing history, shopping preferences, hobbies, etc.; 3. The account is stolen, bypassing login verification, directly accessing the user's account, etc.

With the popularity of the Internet, we use browsers to surf the Internet have become a way of life. In the daily use of browsers, we often encounter situations where we need to enter account passwords, such as online shopping, social networking, emails, etc. This information needs to be recorded by the browser so that it does not need to be entered again the next time you visit. This is when cookies come in handy. What are cookies? Cookie refers to a small data file sent by the server to the user's browser and stored locally. It contains user behavior of some websites.

The working principle of cookies involves the server sending cookies, the browser storing cookies, and the browser processing and storing cookies. Detailed introduction: 1. The server sends a cookie, and the server sends an HTTP response header containing the cookie to the browser. This cookie contains some information, such as the user's identity authentication, preferences, or shopping cart contents. After the browser receives this cookie, it will be stored on the user's computer; 2. The browser stores cookies, etc.
