Welcome Guest, Not a member yet? Register   Sign In
SESSION variable size ...
#1

[eluser]sikko[/eluser]
Hi there,

I've got some trouble with session->user data.
I want to save an array in session. And I want this array to be quiet big (50-100 lines).

The array is composed of String variables. Here is a test to show you the problem:

Code:
function add(){

        $playListElement = '0UjsXo9l6I8:"Empire State of Mind" Jay-Z | Alicia Keys [OFFICIAL VIDEO]';
        
        for ($i=0; $i<50; $i++)
        {
            // initialise la playliste
            $playlist = $this->session->userdata('playlist');
            
            // si la playlist n'existe pas
            if(!$playlist)
                $playlist = array();

            $playlist[] = $playListElement;

            $this->session->set_userdata('playlist', $playlist);
        }
    }

The problem is that when I use $this->session->set_userdata, the size of the array is "limited".
And I will be able to save only 33 "$playListElement" in my array. The bigger are the saved Strings, the less I can save (for a bigger string, I can only have 19 elements. etc.)

But when I run this code in pure PHP:


Code:
session_start();
$playListElement = '0UjsXo9l6I8:"Empire State of Mind" Jay-Z | Alicia Keys [OFFICIAL VIDEO]';

for ($i=0; $i<20; $i++)
{
    // initialise la playliste
    $playlist = $_SESSION["playlist"];

    // si la playlist n'existe pas
    if(!$playlist)
        $playlist = array();

    $playlist[] = $playListElement;

    $_SESSION["playlist"] = $playlist;
}
echo "<pre>";
print_r($_SESSION["playlist"]);
echo "</pre>";

There is absolutely no problem: I can save a lot of String, with quasi no limitation (I've saved over 700 elements and I could do more...)

So now, I know the problem is not from PHP session variable size, but from CodeIgniter session variable size...

Do you know how can I bypass this problem ? Or should I just use the $_SESSION variables ?
#2

[eluser]sikko[/eluser]
Does anybody have an idea ?
#3

[eluser]jmadsen[/eluser]
Check out:

http://codeigniter.com/wiki/Category:Lib...::Session/

I believe the root of the problem for you is that CI Sessions are cookie based, and limited to (?) 4k in size... the link above talks more about it, and some alternatives.
#4

[eluser]sikko[/eluser]
Ok thanks.

So I think I will use "Native Session" library to do it.

Thank you for your help! Smile




Theme © iAndrew 2016 - Forum software by © MyBB