Passing variable with data to different pages

preview_player
Показать описание

There are different ways to transfer data between pages. If you are logged in then your user id is displayed at the top right of this page. As we move to different pages our user id also moves to these pages. If you are logged in to YouTube then you can see this feature as you watch this video.
Usually there are four ways to take user entered data to different Pages.
Session
Cookies
URL
FORM

Using Session the data is stored at server end. Usually short data like login status, userid etc are stored using session variables. Different pages can read the session related data of the user by using session unique identification number or session ID. This is a secure way of storing data and transferring to different pages as user can’t tamper the data at server end. As visitor related details are stored at server end so more server resources are consumed particularly for high traffic sites.

Cookies are stored at client end so we can store more visitor related data. Different pages can read the stored cookies data at client end and process the data. However user browser setting may reject accepting cookies from server as the control of storing data remains with client. As the data is stored locally , the user can tamper the data so sensitive information should not be stored using cookies. Data like user preferences , choice of colour or brand , purchase history , preferred currency of payment etc can be stored using cookies. Cookies also enhance user experience as the preferences of previous visits are available and can be set as default. Once the user changes its compute user related data is lost.
Google 2 step verification: You can skip the 2 –step verification for the computers you trust as you have set remember me in this computer.
URL or address bar
Links or GET method of form posting is used to pass data using the address bar. A name value pair is crated by using a form or by using link and the data is passed to targeted page. The name value pair is then received by targeted page and collected the data using the name and use it for further processing. There is a security issue here as data is exposed at address bar and any one can view the sensitive information by visiting history or by reading from address bar. Even the data can be changed while sending (injection attack) . There is a restriction in amount of data you can transfer due to the restriction in address bar. The advantage is we can bookmark the URL ( with data ) or send it to any friend.
POST method.
Here post method uses header to pass the data to the action page. Usually after receiving the data from source page, session variables or cookies are used to further store the data. In a login page information posted by user is passed by POST method and the details are verified and session data is crated which can be accessed by other pages.
Рекомендации по теме
Комментарии
Автор

Fabulous!, Clear explanation sir, I wanna see you with the same explanation & example in other videos also.. Thanks a lot.

abdulaziz
Автор

thanks you deserve more subs i checked 20 video and nothing before i find this

minasseracnr
Автор

Is there way to get a variable from a SQL query to another page?

For instance if I click on a particular user in a list of users PHP takes me to the next page with the user details?

The first page is the result of a SQL query showing results of users but I want to click on the user to get the users details?

pnruk
Автор

It shows: Undefined array key "my_name" when reloading the page2.php from the address bar.

adamone