From the course: PHP for Web Designers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using PHP sessions to preserve data

Using PHP sessions to preserve data - PHP Tutorial

From the course: PHP for Web Designers

Start my 1-month free trial

Using PHP sessions to preserve data

Data submitted from a form is passed through the post or get array to the next page or script but it's not automatically preserved. It's the job of the processing script to do something with the data before it's cleared from the server's memory. Often, that's not a problem, because the script that processes the form data, will insert it into a database, or send it as an email message. But if you want the data to remain available after the user moves to another page, you need to store it. One way to do so, is to store it in hidden form fields in the next page. But if the user goes to a different page rather than the one that processes the hidden form fields, the data disappears into cyber oblivion. You need a more robust way of preserving the data until it's no longer needed. A common way of doing so is to use cookies. These are named value pairs that are stored in the browser, and they're sent to the web server with each page request. The disadvantage with cookies is that the same…

Contents