如何使用会话存储搜索结果?

时间:2014-01-11 04:06:43

标签: javascript php

我需要存储用户的搜索结果,并在回发时再次显示结果。

2 个答案:

答案 0 :(得分:1)

     <?php session_start();  //to start session

      $_SESSION['search_result'] = $_REQUEST['search_result'];

     //$_REQUEST['search_result'] is the data you get from GET Mehthod or POST Method of variable search_result


     ?>



      To acess it on other page

      <?php

      session_start();
      $search_result = $_SESSION['search_result'];

答案 1 :(得分:0)

你可以:

//page 1
session_start();
$_SESSION['postback'] = serialize($msg);
//page 2
session_start();
$msg = isset($_SESSION['postback'])?unserialize($_SESSION['postback']):'';

但是,不要使用这样的会话。