Apr 07, 2011 — 5 comments
A handy PHP code snippet which detect whether the visitor is logged in or not in WordPress.
In my last post I talked about Session In PHP . Today I will be discussing Practical Use Of Session In PHP. This is going to be a straight forward tutorial, we are going store information in session and use the information across multiple pages. So let get started. Open your favorite text editor (Notepad), paste the code below in it and save as page1.php
Today, we will be looking at session in PHP. Session is a way to store information in variables to be used a crossed multiple pages. Session can be useful when you want to pass information across multiple pages and you want the information stored on the server. A simple session can be illustrated when you open an application, makes some changes then closes it. This process (opening, changing and closing of the application) represent a complete session.
A normal HTML website will not pass data from one page to another. In other words, all information is forgotten when a new page is loaded. This makes it quite a problem for tasks like a shopping cart, which requires data(the user’s selected product) to be remembered from one page to the next. Using session and cookie, helpful to keep track every movement of the visiting web page information.
If your website handles multiple subdomains and you want to retain the session while a user navigates through them. Here is a quick and easy fix.
Learn how to make a class to manage secure sessions on your PHP pages.
This is a very detailed tutorial about using PHP sessions. A session is like a variable that can transfer data between more pages.
Sessions is a good way for storing temporary data between your pages. A session is usually closed pretty fast after that the user have left the site so as I said, it's good for temporary storage, an example is the user's name or items the user have put in his/her shopping cart.
Help us out! More and more tutorials are submitted to Good-Tutorials each day. We could use your help with finding good tutorials. Mind lending a hand?