会话没有设定,为什么?

时间:2014-09-28 18:45:54

标签: php

我有这段代码:

 <?php
    session_start();
    $cislonak=$_GET['cislonakupu'];
     $_SESSION['cislonakupu'] = $cislonak;

    $sessionnakupu = $_SESSION['cislonakupu'];
    echo $sessionnakupu;
    ?>

会话仅适用于以下网站:shoppingcart.php?cislonakupu = 123456789 ......

在index.php上它不起作用。 问题在哪里?

1 个答案:

答案 0 :(得分:0)

试试这个:

<?php
session_start();
if(isset($_GET['cislonakupu'])) {
  $cislonak = $_GET['cislonakupu'];
  $_SESSION['cislonakupu'] = $cislonak;
}
if(isset($_SESSION['cislonakupu'])) {
  $sessionnakupu = $_SESSION['cislonakupu'];
  echo $sessionnakupu;
}
?>