How to Use Sessions With WordPress
The PHP session class lets you create sessions for use in your WordPress blog pages. WordPress includes a PHP editor with which you edit and customize the WordPress installation. You use sessions to store information while the user is logged into the page. You can log any information in the same way that you save a variable value, but the session class stores unique variables that correspond only to the specified user accessing the Web page.
Instructions
-
-
1
Open a Web browser and log into the WordPress dashboard using your user name and password.
-
2
Click the Appearance left panel link. Click Editor to open the editor. Click the header.php page to open the code for the main header file. The header file is the typical location for session variables, but you can use any file in your WordPress app.
-
-
3
Add the following code to the editor:
session_start()
$_SESSION["myid"] = "value";Replace "myid" with the name of your session and replace "value" with the value you want to store in the session variable.
-
4
Click "Update" in the editor window to save the changes to your blog page. The changes take effect immediately.
-
1