php session数组 存值和取值

存值:

session开启

 session_start();

 

数组变量

$mybasket = array();

循环赋值

$mybasket[$value] = 0;

 

保存到session

 $_SESSION['mybasket']= $mybasket;

 

取值:

session开启

 session_start();

foreach($_SESSION as $parm=>$value):

  if (is_array($value)) {
   
   foreach ($value as $key => $v):
   echo $key . " -> " . $v;
   endforeach;
  }
  endforeach;

 

 session_destroy();全部清空;

unset $_SESSION['mybasket']; 部分清空.

你可能感兴趣的:(PHP,session,数组,取值,存值)