Home Backend Development PHP Tutorial Does Session have to rely on Cookie_PHP Tutorial

Does Session have to rely on Cookie_PHP Tutorial

Jul 13, 2016 pm 04:58 PM
cookie session rely

Does Session have to rely on Cookie?
www.ouryh.net Galaxy Technology OnlineㄕCompilation time: 2001-8-7ㄕAuthor: UnknownㄕSource: UnknownㄕReads: 36

Session in PHP can be defaulted In this case, the client's Cookie (to distinguish it from Cookie in the ordinary sense, I call it session cookie, and Cookie in the ordinary sense is Cookie) is used to save the session id, but can sessions in PHP only use session cookies? ?Of course not, otherwise why bother to create a session? It is better to just use Cookie. One of the great advantages of Session is that when the client's Cookie is disabled, the session id will be automatically attached to the URL, so that it can be remembered through the session id. The session variable is stored.
I will write two files below to confirm. First, disable cookies in the browser.
session_start();
session_register("url");
$url="test2.php";
echo "goto test2.php
";
? >
session_start();
if (session_is_registered("url")) {
echo "Congratulations.
";
$url="test1.php";
echo "goto test1.php
";
}
else echo "Failed.
";
?>
Now enter "http://localhost/test1.php" in the browser, move the mouse over the link and look at the address on the status bar. It is not a simple "http: //localhost/test2.php", but in this form: "http://localhost/test2.php?PHPSESSID=6e3610749f7ded3784bc4a4dd10f879b". You can also view the Html source file, which is in this form:
goto test2.php
So this is entirely the result of PHP and has nothing to do with the browser, that is to say, no matter what browser you use It is valid for all sessions, not only for IE as some people think.
However, our hyperlink statement is output by the echo statement. If the hyperlink is not included in the PHP tag What will happen? Let’s write an example to verify it. Modify test1.php slightly:
session_start();
session_register("url");
$url= "test2.php";
echo "goto test2.php
";
?>
(Html ​​form)goto test2.php

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631421.htmlTechArticleDoes Session have to rely on Cookies? www.ouryh.net Galaxy Technology OnlineㄕCompilation time: 2001-8-7ㄕ Author: Unknown Source: Unknown Reading: 36 Session in PHP can be used by default...
Statement of this Website
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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to solve session failure How to solve session failure Oct 18, 2023 pm 05:19 PM

Session failure is usually caused by the session lifetime expiration or server shutdown. The solutions: 1. Extend the lifetime of the session; 2. Use persistent storage; 3. Use cookies; 4. Update the session asynchronously; 5. Use session management middleware.

Where are the cookies on your computer? Where are the cookies on your computer? Dec 22, 2023 pm 03:46 PM

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.

Where are cookies stored? Where are cookies stored? Dec 20, 2023 pm 03:07 PM

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.

Solution to PHP Session cross-domain problem Solution to PHP Session cross-domain problem Oct 12, 2023 pm 03:00 PM

Solution to the cross-domain problem of PHPSession In the development of front-end and back-end separation, cross-domain requests have become the norm. When dealing with cross-domain issues, we usually involve the use and management of sessions. However, due to browser origin policy restrictions, sessions cannot be shared by default across domains. In order to solve this problem, we need to use some techniques and methods to achieve cross-domain sharing of sessions. 1. The most common use of cookies to share sessions across domains

Where are the mobile cookies? Where are the mobile cookies? Dec 22, 2023 pm 03:40 PM

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.

CentOS installation gnuplot and CentOS installation sunflower are missing dependencies CentOS installation gnuplot and CentOS installation sunflower are missing dependencies Feb 13, 2024 pm 11:39 PM

LINUX is a widely used operating system that is highly customizable and stable. CentOS is a free and open source operating system built on the Red Hat Enterprise Linux (RHEL) source code. It is widely used in servers and desktop environments. In CentOS Installing software packages on CentOS is one of the common tasks in daily use. This article will introduce how to install gnuplot on CentOS and solve the problem of missing dependencies of Sunflower software. Gnuplot is a powerful drawing tool that can generate various types of charts, including two-dimensional and three-dimensional data visualization. To install gnuplot on CentOS, you can follow the steps below: 1.

What are the dangers of cookie leakage? What are the dangers of cookie leakage? Sep 20, 2023 pm 05:53 PM

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.

Detailed explanation of where browser cookies are stored Detailed explanation of where browser cookies are stored Jan 19, 2024 am 09:15 AM

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.

See all articles