时间:2021-07-01 10:21:17 帮助过:21人阅读
php中可通过$_SESSION保存session变量,下面的代码简单演示了 $_SESSION的用法
<?php session_start(); print(""); $_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("\n"); ?>
上面的代码输出结果如下:
A value saved in the session named as MyLogin. A value saved in the session named as MyColor. W3M red
希望本文所述对大家的php程序设计有所帮助。