Home > Backend Development > PHP Tutorial > How to set up session after disabling cookies

How to set up session after disabling cookies

WBOY
Release: 2016-07-29 09:13:47
Original
1002 people have browsed it

We all know that there are two ways to pass SESSIONID in the session based on cookie and url. In order to prevent the client from sending cookies without affecting the customer's login to the website, you can set session.use_trans_sid=1 in php.ini, which means that when the client browser disables cookies, the links on the page will pass the SESSIONID based on the URL. However, many people only set this option and it did not achieve the effect. I also encountered this problem. After some research, I found that there are two options in the php.ini file
session.use_cookies=1
session.use_> Think about it carefully You will find the meaning of the above English
session.use_cookies indicates whether to start a session based on cookies
session.use_only_cookies indicates whether to only open a session based on cookies

So if you want to use a session based on cookies when turning on cookies in the browser Cookie method, use the URL method when cookies are not turned on and set it as follows (the most commonly used method, recommended)

In the php.ini file
session.use_trans_sid=1
session.use_>session.use_cookies=1
Or in the php program
ini_set("session.use_trans_sid","1");
ini_set("session.use_only_cookies",0);
ini_set("session.use_cookies",1);
If it doesn’t matter whether the browser is turned on or not Cookies are set as follows using URL (this example mainly wants to explain the difference between setting session.use_only_cookies and session.use_cookies)
In the php.ini file
session.use_trans_sid=1
session.use_>session.use_cookies =0
Or in php program
ini_set("session.use_trans_sid","1");
ini_set("session.use_only_cookies",0);
ini_set("session.use_cookies",0);

Do it yourself Give it a try and you will understand the difference between session.use_only_cookies and session.use_cookies.

The above introduces how to set up the session after disabling cookies, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template