Home  >  Article  >  Backend Development  >  Knowledge points related to user login in PHP (2)

Knowledge points related to user login in PHP (2)

不言
不言Original
2018-04-27 13:42:301462browse

This article mainly introduces the relevant knowledge points about implementing user login in PHP (2). It has certain reference value. Now I share it with everyone. Friends in need can refer to it

3.4 Successful jump--PHP session technology3.4.1 Why should we have session technology

The characteristics of HTTP protocol are stateless/connectionless. When a browser requests the same web server multiple times in succession, the server cannot distinguish whether multiple operations come from the same browser (user).

Session technology is to find a way through the HTTP protocol to allow the server to identify multiple requests from the same browser, so that the browser (user) can continue to access the same website multiple times. No additional authentication is required.

3.4.2 The difference between session and cookie

##1. Security aspects    

Session is stored on the server side, with high security. Cookies are stored on the browser side, with low security.

2. In terms of data size, the number and size of cookies are limited (20/4K) and there is no limit to session data storage

3. Available data types Cookie can only store simple data, values/strings Session can store complex data (automatic serialization)

4. In terms of storage location, the cookie is saved on the browser and the session is saved on the server.

##3.4.3 Record the session after successful login

[PHP]

Plain text view

Copy code

?

1

2

3

4

5

6

7

8


//开启session
session_start();
//存储登录信息
$_SESSION['user']="";
//验证用户是否登录 判断是否存在$_SESSION['user']
if(!$_SESSION['USER']){
   
}



4.PHP常用的跳转方法-heade

[PHP] 纯文本查看 复制代码

?

1

2

3

4


方法一:
  header("location:跳转url");       //直接跳转不带有提示信息
  header("refresh:秒;url=新地址");  //延时跳转
      注意:header前不能有任何输出语句
相关推荐:

关于PHP实现用户登录相关知识点(一)

The above is the detailed content of Knowledge points related to user login in PHP (2). 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