【问题标题】:How to store the session values in array in cake php3如何将会话值存储在 cakephp 3 中的数组中
【发布时间】:2015-12-03 17:57:17
【问题描述】:

在 cake php 中,我使用 session 来存储值,但每次会话都被新的 session value 覆盖。所以我使用数组来存储 session 值并列出我对 cake PHP 3 不熟悉的所有 session 值任何人的帮助。

$session = $this->request->session();
$session->write('search', $repeats);

这里我在 cake php 中创建一个会话

【问题讨论】:

  • CakePHP 可以很好地处理会话。如果您能澄清您的问题,我们可以尝试帮助...特别是您想要做什么以及您的意图。
  • 会话名称必须以不同的名称保存,例如 $session1,$session2,$session3 通过使用数组可以在 cake php.to 列出所有会话值。
  • 我认为你应该看看这个:book.cakephp.org/3.0/en/development/sessions.html

标签: php arrays session cakephp cakephp-3.0


【解决方案1】:

是的,cakephp 允许您将会话值存储在数组中

//Sample:
$this->Session->write('User.email', 'abc@example.com');
$this->Session->write('User.phone', '090x108986');
$this->Session->write('User.site', 'http://rao5s.vn');
// Now you can read a array from Session
$arrUser = $this->Session->read('User');

【讨论】:

    猜你喜欢
    • 2017-01-22
    • 2015-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-15
    • 1970-01-01
    相关资源
    最近更新 更多