【发布时间】:2023-11-11 11:20:01
【问题描述】:
有什么方法可以在不使用 uri 的情况下在 CI 中传递变量。例如,除了将变量发送到这样的 uri 之外:
index.php/user/search/name/joe/location/UK/gender/male
有没有其他方法可以传递变量而不使用 URI?
【问题讨论】:
标签: php codeigniter codeigniter-url
有什么方法可以在不使用 uri 的情况下在 CI 中传递变量。例如,除了将变量发送到这样的 uri 之外:
index.php/user/search/name/joe/location/UK/gender/male
有没有其他方法可以传递变量而不使用 URI?
【问题讨论】:
标签: php codeigniter codeigniter-url
查看会话类:http://codeigniter.com/user_guide/libraries/sessions.html
设置数据:
$user = array(
'name' => 'joe',
'location' => 'UK',
'gender' => 'male'
);
$this->session->set_userdata($user);
获取数据:
$name = $this->session->userdata('name');
... etc.
您也可以将数据存储在 cookie 中:
见:http://codeigniter.com/user_guide/helpers/cookie_helper.html
【讨论】:
$_POST 或 $_SESSION 而不是 $_GET :-)
【讨论】:
$_POST 或 $_SESSION 如果只想设置一些消息,您可以使用 $this->session->set_flashdata('SOME_KEY','Logged in or blah blah'); CI 使用其会话类将其发送到下一页
【讨论】: