首页 > 解决方案 > $_SESSION 变量在第二页上不起作用

问题描述

我在第一页创建了一个会话:

<?php 
  $youtubeID = get_sub_field('youtube_id'); 
  $withlastSlash = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
  $withoutSlash =  substr_replace($withlastSlash, "", -1);
  $howtoURL = $withoutSlash . "?a=" . $youtubeID;
  session_start();
  $_SESSION['howtovidsurl'] = $howtoURL;
?> 

然后我在第二页中调用了会话变量

<?php
    session_start(); 
    echo $_SESSION['howtovidsurl']; 
?> 

但是在第二页上没有任何回应。

标签: php

解决方案


推荐阅读