简体   繁体   English

如何在Codeigniter中将数组从一个函数传递给另一个函数

[英]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. 您可以在此问题上有两个选择。

  1. Don't store every data in session. 不要在会话中存储所有数据。 Store somthing unique. 存放独特的东西。

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并将请求发送到数据库并获取用户信息。 .

  1. Can use session tables which provided by Codeigniter. 可以使用Codeigniter提供的会话表。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将数组值从一个函数传递到另一个函数,并使用Codeigniter将其发送以查看页面? - How to pass the array value from one function to another function and send it to view the page using Codeigniter? 如何在Codeigniter中将变量从一个函数传递给另一个函数 - how to pass variable from one function to another function in codeigniter 如何在codeigniter中将数组从一个类控制器传递到另一个类控制器 - how to pass an array from one class controller to another in codeigniter 如何通过使用会话将数据从一个功能传递到Codeigniter中的另一个功能? - How to pass data from one function to another in codeigniter by using session? CodeIgniter:如何将值从特定函数传递给另一个函数 - CodeIgniter: how to pass values from a specific function to another one 我想将变量从一个函数传递给Codeigniter中的另一个函数 - I want to pass variables from one function to another function in codeigniter Codeigniter:如何将输入值从一个函数传递到控制器内的另一个函数 - Codeigniter: How to pass input values from one function to another function inside a controller 如何将数据数组从一个钩子 function 传递到 WooCommerce 中的另一个 - How to pass a data array from one hooked function to another in WooCommerce 如何将数据从一个视图页面传递到codeigniter中的另一个视图? - how to pass the data from one view page to another view in codeigniter? 在CodeIgniter中将变量从一页传递到另一页 - Pass a variable from one page to another in CodeIgniter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM