PHP method to save information to the current Session

墨辰丷
Release: 2023-03-31 19:00:01
Original
1545 people have browsed it

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[&#39;sitename&#39;]."\n";
 echo $_SESSION[&#39;MyChoice]."\n";
 print("</b></html>\n");
?>
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!