PHP Disable cookie After session setting method analysis _php Skill

Source: Internet
Author: User

This example describes the session setting method after PHP disables cookies. Share to everyone for your reference, specific as follows:

We all know that when in session sessions there is a method based on cookies and two kinds of delivery sessionid based on URLs. In order to implement a client-side ban on the sending of cookies does not affect the client landing site, you can set up php.ini in Session.use_trans_sid=1, indicating that when the client browser prohibits cookies, The link on the page will pass SessionID based on the URL. But a lot of people just set this one option does not achieve the effect, I also encountered this problem, and later a study found

There are two more options in the php.ini file

Session.use_cookies=1
Session.use_only_cookies=1

You'll find the meaning of the English language.

Session.use_cookies indicates whether to start session sessions based on cookies
Session.use_only_cookies Indicates whether session mode is open only based on cookies

So if you want to use a cookie based on the cookie in the browser when you open the cookie, you can do the following by using the URL in the way that you do not open cookies (the most common way to recommend)

In the php.ini file:

Session.use_trans_sid=1
session.use_only_cookies=0
Session.use_cookies=1

Or in a PHP program,

Ini_set ("Session.use_trans_sid", "1″");
Ini_set ("Session.use_only_cookies", 0);
Ini_set ("Session.use_cookies", 1);

If the browser does not open cookies, use the URL method to do the following settings (this example is mainly 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_only_cookies=0
session.use_cookies=0

Or in a PHP program,

Ini_set ("Session.use_trans_sid", "1″");
Ini_set ("Session.use_only_cookies", 0);
Ini_set ("Session.use_cookies", 0);

Try it yourself and you'll understand the difference between session.use_only_cookies and session.use_cookies.

More about PHP Interested readers can view the site topics: "PHP Design Security Course", "PHP object-oriented Program Design Introductory Course", "PHP Mathematical Calculation Skills Summary", "PHP Array" Operation Techniques Encyclopedia, "PHP string (String) Usage summary, "PHP Data structure and algorithm tutorial", "PHP Programming algorithm Summary" and "PHP common database Operation skill Summary"

I hope this article will help you with the PHP program design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.