Tools, FAQ, Tutorials:
Saving Values in the Session in PHP
How To Save Values to the Current Session in PHP?
✍: FYIcenter.com
When session is turned on, a session will be automatically created for you by the PHP engine. If you want to save any values to the session, you can use the pre-defined associative array called $_SESSION. The following PHP script shows you how to save values to the session:
<?php session_start(); print("<html><pre>"); $_SESSION["MyLogin"] = "FYICenter"; print("A value saved in the session named as MyLogin.\n"); $_SESSION["MyColor"] = "Blue"; print("A value saved in the session named as MyColor.\n"); print("Click <a href=next_page.php>Next Page</a>" ." to retrieve the values.\n"); print("</pre></html>\n"); ?>
If you save this script to your Web server as first_page.php and visit it with a browser, you will get:
A value saved in the session named as MyLogin. A value saved in the session named as MyColor. Click Next Page to retrieve the values.
2016-10-26, 803👍, 0💬
Popular Posts:
How To Submit Values without Using a Form in PHP? If you know the values you want to submit, you can...
Where to find tutorials on Using Azure API Management Developer Portal? Here is a list of tutorials ...
What is Azure API Management Developer Portal? Azure API Management Developer Portal is an Azure Web...
Why Do You Need to Filter Out Empty Files in PHP? When you are processing uploaded files, you need t...
Where to find tutorials on JSON (JavaScript Object Notation) text string format? I want to know how ...