Home  >  Article  >  Backend Development  >  PHP implements session multi-domain name and multi-server sharing session_id_PHP tutorial

PHP implements session multi-domain name and multi-server sharing session_id_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:10:26917browse

We can save the sessionid in the database to achieve this. This method is relatively safe and widely used, but it is not the scope of our discussion. Below we will only talk about simple

First generate a sessionid during verification;

 代码如下 复制代码
Session_start();
$sessionId = session_id();//得到sessionid

//将session下发给客户端
.........
?>

The client carries the sessionid variable to request data

 代码如下 复制代码

Session_id(‘$sessionid’);//注意这个时候session_id()这个函数是带有参数的
Session_start();//这个函数必须在session_id()之后

?>

The problem of multi-server sharing session, everyone should be able to understand this, when a website If the number of users is too large, a server cluster will be used, for example, a dedicated server for login. After the user logs in through the login server, the login server saves the user's login information session, and other accessed servers, such as the movie server, do not have this session, so we have to share this session through a unique identifier of the session


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/444732.htmlTechArticleWe can save the sessionid in the database to achieve this. This method is safer and widely used, but it is not what we are discussing. Scope, let’s just talk about the simple first verification...
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