Home  >  Article  >  Backend Development  >  Do you know the security issues of php session?

Do you know the security issues of php session?

怪我咯
怪我咯Original
2017-07-05 09:43:55958browse

An attacker invests a lot of effort in trying to obtain the valid session ID of an existing user. With the session ID, they may be able to have the same capabilities as this user in the system.

Therefore, Our main solution is to verify the validity of session ID.
The following is the content of quoting:

The code is as follows:

<?php 
if(!isset($_SESSION[&#39;user_agent&#39;])){ 
$_SESSION[&#39;user_agent&#39;] =$_SERVER[&#39;REMOTE_ADDR&#39;].$_SERVER[&#39;HTTP_USER_AGENT&#39;]; 
} 
/* 如果用户session ID是伪造 */ 
elseif ($_SESSION[&#39;user_agent&#39;] != $_SERVER[&#39;REMOTE_ADDR&#39;] .$_SERVER[&#39;HTTP_USER_AGENT&#39;]) { 
session_regenerate_id(); 
} 
?>

The above is the detailed content of Do you know the security issues of php session?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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