[英]How to pass an array from one function to another in codeigniter
I need to pass an array from one function to another. 我需要将数组从一个函数传递给另一个函数。 I tried with session variables.
我尝试了会话变量。
$array;
$this->session->set_userdata('array',array);
$array = $this->session->userdata('array');
but it does not work for older arrangements 2KB. 但是不适用于2KB的旧版本。
I read that you can not spend such a long array, that session variables are stored in cookies on the browser and does not allow more than 2 or maximum 4KB according to the browser. 我读到,您不能花费那么长的数组,会话变量存储在浏览器中的cookie中,根据浏览器,不允许超过2个或最大4KB。
I tried to serialize also. 我也尝试序列化。 Any ideas?
有任何想法吗?
Switch sessions to database, then you can store larger amount of data. 将会话切换到数据库,然后您可以存储大量数据。 See http://www.codeigniter.com/user_guide/libraries/sessions.html#database-driver for details.
有关详细信息,请参见http://www.codeigniter.com/user_guide/libraries/sessions.html#database-driver 。
You have two option on this issue. 您可以在此问题上有两个选择。
Explenation: if your database having all the user data and you are trying to store all the in session.
解释:如果您的数据库具有所有用户数据,并且您尝试存储所有in会话。 Its worthless.
它一文不值。 Just store user id with session time So when ever you need and user data you can call the session user id and send request to database and get the user information.
只需将用户ID与会话时间一起存储,因此,无论何时需要和用户数据,都可以调用会话用户ID并将请求发送到数据库并获取用户信息。 .
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.