Php:会话不起作用?

时间:2015-05-10 06:05:08

标签: php

<?php

    if(isset($_POST['btnLogin']))

        {

             $id = $_POST['email'];

             $pass = $_POST['password'];

         // Resource Address

            $url ="http://localhost:81/RouteApp/ViewApi/?id=$id&pass=$pass";

         // Send Request To Resource

            $client = curl_init($url);

            curl_setopt($client,CURLOPT_RETURNTRANSFER,1);

         // get Response To Resource

            $response = curl_exec($client);


         // Decode it

            $result = json_decode($response);
            session_start();
             $res  =   (array)$result->data;
             foreach ($res as $key) {
                 $_SESSION['sessId']=$key[0];
                 $_SESSION['sessName']=$key[1];
                 $_SESSION['sessEmail']=$key[2];
             }

           header("Location:index.php");
        }
?>

1 个答案:

答案 0 :(得分:0)

每次使用会话时,都需要使用session_start()函数启动或恢复会话。