Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

TutsPlus.com:
How to Use Sessions and Session Variables in PHP
Oct 04, 2018 @ 16:43:35

If you're new to PHP and are still learning the ropes, one thing that could be confusing is how the language handles sessions and the data they contain. In this new tutorial from the TutsPlus.com site, they introduce you to the basics of using sessions and the variables they contain to get you up to speed.

Session handling is a key concept in PHP that enables user information to be persisted across all the pages of a website or app. In this post, you'll learn the basics of session handling in PHP.

We'll start with an explanation of how sessions work and how they are related to cookies. Then we'll look at a few code snippets that demonstrate how to work with sessions. You'll learn how to create and destroy sessions, and how to change session variables.

The post starts with a general overview of what a session is and how the information flows back and forth from the user to the server. To illustrate, they provide an example of a simple login process, complete with flow diagram. The tutorial then shows how to:

  • start a new session
  • get the session ID
  • automatically start a session
  • destroying a session

It then covers the use of session variables: setting them, removing them and altering their contents.

tagged: session handling tutorial introduction start destroy variable

Link: https://code.tutsplus.com/tutorials/how-to-use-sessions-and-session-variables-in-php--cms-31839


Trending Topics: