[Solved] session variable vs normal variable? [closed]


Where is the value stored?

That depends on the PHP configuration. By default, session variables are serialized and written into a file on the server’s file system. On each page view that starts the session, they are unserialized and accessible from the $_SESSION array. It’s possible to override the default session handler so that you can store the variables elsewhere, such as a database.

Sessions work by storing a session ID (which is a unique identifier) as a cookie on the client’s computer. Each time the client requests a page, the session ID cookie is sent along with the request, PHP picks up the session ID from the cookie, and then pulls the sesssion data that relates to said session ID.

what is the difference between a session variable and a normal variable?

Simply put, a session variable gets saved to a source (such as file system), this is how they can persist between page requests. A normal variable will only live until the execution of the script completes, it will then be destroyed.

solved session variable vs normal variable? [closed]