A simple method makes background logon more secure (adding session verification in php)

Source: Internet
Author: User
Register the session through a specific file as the background entry; otherwise, the session fails to exit. You cannot log on to the background directly using the original background address. In this way, the diversity and changeable nature of the entry file name will provide a safer environment for your background login. This article uses Joomla! The background link is used as an example to explain how to "modify" our background link to make it more secure.

Principle: use a specific file to register a session for the background Portal. Otherwise, the session fails to exit. You cannot log on to the background directly using the original background address. In this way, the diversity and changeable nature of the entry file name will provide a safer environment for your background login.

1. entry File: myadmin. php (the file name can be changed at any time)

Purpose: register a session. The source code is as follows:

The code is as follows:

  
 

[Html]
2. modify the background Portal File:/administrator/index. php (it can start with any CMS portal file)

Purpose: access through session control. The source code is as follows:

[Code]

Define ('_ JEXEC', 1); // Line 9 define ('DS ', DIRECTORY_SEPARATOR) of the original file ); // original file Line 10 // Add session_name ("Zjmainstay"); session_start (); $ OK _to_browse = ($ _ SESSION ['admin _ user'] = "Y"); if (! $ OK _to_browse) {header ("Content-type: text/html; charset = utf-8"); exit ('deny unauthorized access! ');} Else {$ _ SESSION ['admin _ user'] = "Y"; // use session_write_close () to continue the session;} // Add End

The above is a simple method to make background login more secure (adding session verification in php) content. For more information, please follow the PHP Chinese network (www.php1.cn )!

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.