CodeIgniter Forums

Full Version: Session processing degrades the performance greatly
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]joneslee[/eluser]
Can someone suggest me a way to detect why my 2 lines of code:

Code:
$this->session->unset_userdata('menu');
$this->session->set_userdata('menu', 'men');

runs fine on my local dev server but so so so slow on the live host?

El Forum

[eluser]Thorpe Obazee[/eluser]
Could it be that there are other things that might be affecting the speed?

El Forum

[eluser]joneslee[/eluser]
I double check and confirm the culprit is the session. I think it could have something to do with 4kb limit. Is there a way to check session size?

El Forum

[eluser]Thorpe Obazee[/eluser]
I believe Firebug can check it.

El Forum

[eluser]huuthanh3108[/eluser]
you can check it on firefox

El Forum

[eluser]joneslee[/eluser]
Could you show me how? I was googling around for the way

El Forum

[eluser]Thorpe Obazee[/eluser]
if you have firebug, you can see it in the cookies tab.

El Forum

[eluser]huuthanh3108[/eluser]
//file config.php add a line
// two value 'CI' or 'PHP'
Code:
$config['sess_mode']        = 'PHP';

and create file MY_Session.php in folder library: My_Session.php
Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$CI = & get_instance();
if($CI->config->item('sess_mode') == "PHP")//config use session of PHP
{
    class MY_session
    {
        function MY_session()
        {
            session_start();
        }
        function userdata($name)
        {
            if($name == "session_id")
                return session_id();
            else
            {
                return isset($_SESSION[$name])?$_SESSION[$name]:'';
            }
        }
        function set_userdata($name, $value)
        {
            $_SESSION[$name] = $value;
        }
        function unset_userdata($name)
        {
            $_SESSION[$name] = '';
        }
    }
    
}
else//config use session CI
{
    class MY_session extends CI_session
    {
        function MY_session()
        {
            parent::CI_Session();
        }
    }
}
?>