Home > Backend Development > PHP Tutorial > tp框架中的session 取不到值是怎么回事

tp框架中的session 取不到值是怎么回事

WBOY
Release: 2016-06-06 20:06:39
Original
1806 people have browsed it

查了很多资料说是跨域的问题。 究竟怎么回事 明明

<code>            $unionid=$userinfo['unionid'];
            session('unionid',"$unionid");
            
            
            但就是在别的方法里取不到</code>
Copy after login
Copy after login

回复内容:

查了很多资料说是跨域的问题。 究竟怎么回事 明明

<code>            $unionid=$userinfo['unionid'];
            session('unionid',"$unionid");
            
            
            但就是在别的方法里取不到</code>
Copy after login
Copy after login

你输出var_dump(session('unionid'));或者var_dump($_SESSION['unionid']);看一下,如果两个都没值,那就说明没赋值成功。
看你的写法是没问题,你可以先自己做个测试,比如

<code class="php">#你的赋值
$unionid=$userinfo['unionid'];
session('unionid',"$unionid");

#测试赋值
session('develop', 'developValue');
$develop = session('develop');
var_dump($develop);
$session = session();
var_dump($session);</code>
Copy after login

你试试可不可以

<code>session_start();
$unionid=$userinfo['unionid'];
$_SESSION['unionid']=$unionid;</code>
Copy after login
Related labels:
php
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