This article mainly introduces the method of php saving information to the current Session. The example analyzes the session usage skills in php. Friends in need can refer to it.
The example of this article tells the story of php saving information to the current session. Session method. The details are as follows:
Session variables can be saved through $_SESSION in php. The following code simply demonstrates the usage of $_SESSION
<?php session_start(); print("<html><b>"); $_SESSION["sitename"] = "W3M"; print("A value saved in the session named as sitename.\n"); $_SESSION["MyChoice"] = "red"; print("A value saved in the session named as MyChoice.\n"); echo $_SESSION['sitename']."\n"; echo $_SESSION['MyChoice]."\n"; print("</b></html>\n"); ?>
The output result of the above code is as follows:
A value saved in the session named as MyLogin. A value saved in the session named as MyColor. W3M red
Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study.
Related recommendations:
PHP uses phpmailer to send emails
##A brief introduction to the decorator pattern in PHP design patterns
A brief introduction to the adapter pattern in PHP design patterns
The above is the detailed content of PHP method to save information to the current Session. For more information, please follow other related articles on the PHP Chinese website!