CodeIgniter Forums
Multidimensional session data - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Multidimensional session data (/showthread.php?tid=3747)



Multidimensional session data - El Forum - 10-19-2007

[eluser]spheroid[/eluser]
How is it possible to do the following refactored for CI? Having difficulty compared to the documentation:

1. Increase the value by 1
Code:
$_SESSION['cart_product_qty'][$i]++;

2. Compare a multidimensional session array key
Code:
if ($_SESSION['cart_product_id'][$i] == $product_id) ...

3. Set a session variable using an array key
Code:
$_SESSION['cart_product_qty'][] = 1;

4. Display a multidimensional session variable
Code:
echo $_SESSION['cart_product_qty'][$i];

I'm not sure if it's possible to use these type of multidimensional session variables??


Multidimensional session data - El Forum - 10-20-2007

[eluser]nmweb[/eluser]
I don't think it's possible right now in the way you described. It is however possible to serialize whichever arrays you have into a variable, unserialize them when you need them, and again serialize them and put them back in the session.

http://nl3.php.net/serialize