我正在使用 flashdata 存储我的搜索查询,以便在用户导航到下一页时检索它。
这就是我存储闪存数据的方式
$this->session->set_flashdata('searchQuery', $queryStr);
这就是我检索闪存数据的方式。
$queryStr = $this->session->flashdata('searchQuery');
Flashdata 在本地运行良好,但是当我将它托管在我的服务器上时,它不能在 Chrome(Windows) 和 Chrome(Android) 上运行,但可以在 IE(Windows) 上运行。它在 Chrome(iOS) 上也可以正常工作。我也做了一个测试用例,它只适用于 IE(Windows) 和 Chrome(iOS)。有谁知道怎么了?
class Flashdata extends MY_Controller {
function __construct()
{
parent::__construct();
$this->load->library('session');
}
function index()
{
if ($var = $this->session->flashdata('test'))
{
echo "Found data: $var";
}
else
{
$this->session->set_flashdata('test', 'flash data test');
echo "Set data";
}
}
}
这是我的 .htaccess 文件
# Options
Options -Multiviews
Options +FollowSymLinks
#Enable mod rewrite
RewriteEngine On
#the location of the root of your site
#if writing for subdirectories, you would enter /subdirectory
RewriteBase /
#Removes access to CodeIgniter system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css
#folders, and the robots.txt file
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php?/$1 [L]