Home  >  Article  >  Web Front-end  >  Several ways to transfer parameters between different pages (answers for you in detail)

Several ways to transfer parameters between different pages (answers for you in detail)

亚连
亚连Original
2018-05-19 11:40:303562browse

The following editor will bring you a discussion on several ways to transfer parameters between different pages. Let me share it with you now and give it as a reference for everyone.

Discussion of several ways to transfer parameters between different pages (Li Sheng)

Since the web system uses the http protocol to transmit data between the browser and the server, and the http protocol is a Stateless protocol, how to transfer data between different pages, there are several ways

Method 1: Form transfer

Passing parameters through a form is the simplest and most basic method of passing parameters. Note: Use of hidden buttons in form elements

Method 2: Transmission via url with parameters

How to write url with parameters: url?parameter name1=value1¶meter name2=value2.

Method 3: Request request object

You can bind data to the request object and read and write through the request object getAttribute and setAttribute methods

Method 4: User session session object

You can bind data to the session object and read and write through the session object getAttribute and setAttribute methods

Method 5: application object

You can bind data to the application object and read and write through the application object getAttibute method and setAttribute method

Method 6: Cookie object

Can write data to the client browser cookie file.

Among them, method one and method two can only realize the transfer of string parameters, and methods three, four, five and six can realize the transfer of objects (method six requires the object to be serialized and stored)

Methods 1, 2, and 3 can only request the page to obtain data through data transfer, while methods 4, 5, and 6 can obtain data objects on multiple different pages.

The data objects saved in methods 4 and 6 are The difference between the information related to a certain user is that method four saves the data to the server memory, while method six saves the data to the client memory.

The data objects saved in method five are information related to all users, and the data is also saved in the server memory.

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

JS refresh page method summary

JS validation input retains specified decimals

JS for E-mail address format verification code

The above is the detailed content of Several ways to transfer parameters between different pages (answers for you in detail). 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