PHPSession insurance-php Tutorial

Source: Internet
Author: User
Tags php session
PHPSession security is recorded in stackoverflow for phpSession security discussions. (Stackoverflow. comquestions328php-session-security) 1. use SSL2. reset session_id reference PHP can: session_regenerate_id (true PHP Session Security
This is a special record of the discussion on php Session Security in stackoverflow. Http://stackoverflow.com/questions/328/php-session-security)


1. use SSL


2. reset session_id

Reference

In PHP, you can: session_regenerate_id (true );




3. set the session validity period

Can refer to the bird brother article: http://www.laruence.com/2012/01/10/2469.html


4. not a global variable


5. store information on the server and do not send important information to cookies.


6. check the user_agent and IP address of the user.

Reference


PHP Usage: if ($ _ SESSION ['User _ agent']! = $ _ SERVER ['http _ USER_AGENT ']

| $ _ SESSION ['User _ IP']! = $ _ SERVER ['remote _ ADDR ']) {

// Something fishy is going on here?

}




7. set httpOnly to avoid Session Attacks

Reference: http://ilia.ws/archives/121-httpOnly-cookie-flag-support-in-PHP-5.2.html


8. Lock down access to the sessions on the file system or use custom session handling

Reference

However, the custom session session_set_save_handler ()
Store sessions in DB and memcached



9. For sensitive operations consider requiring logged in users to provide their authenication details again

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.