$ _SESSION在php中的include文件中不起作用

时间:2016-06-21 01:49:56

标签: php

我的网站结构非常简单,基于include中的php

这里的结构:

<?
    session_start();
    include("lang/".$_SESSION['lang'].".php");
?>
<html>
<body>
...
<? include("menu.php"); ?>
...
</body>
</html>

menu.php的内容是:

<div>
My name is <?= $_SESSION['name']; ?>
</div>

我的问题出在menu.php$_SESSION不再有效。

这是否有原因?

感谢。

1 个答案:

答案 0 :(得分:0)

您没有打印名称。这就是为什么它没有显示。 试试这个

# Set proper headers (these are always the same, so this
# can be assigned outside of the for loop)
headers = {"Content-Type":"application/json","Accept":"application/json"}

# Each POST will send up to 10 records of data
split_size = 10

# Note the two places where our split_size variable is used
for data_point in [j[x:x+split_size] for x in xrange(0, len(j), split_size)]:

    #Build HTTP Request (Note we are using data_point instead of j)
    response = requests.post(url=svcnow_url, auth=(svcnow_user, svcnow_pwd), headers=headers ,data=data_point)

    #Check for HTTP codes other than 200
    if response.status_code != 200:
        print('Status:', response.status_code, 'Headers:', response.headers, 'Response Text', response.text, 'Error Response:',response.json())
    else:
        # This is a response of success for a single record
        print('Status:',response.status_code,'Headers:',response.headers,'Response:',response.json())

exit()