CodeIgniter Forums
Session processing degrades the performance greatly - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Session processing degrades the performance greatly (/thread-18384.html)



Session processing degrades the performance greatly - El Forum - 05-04-2009

[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?


Session processing degrades the performance greatly - El Forum - 05-04-2009

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


Session processing degrades the performance greatly - El Forum - 05-04-2009

[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?


Session processing degrades the performance greatly - El Forum - 05-04-2009

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


Session processing degrades the performance greatly - El Forum - 05-04-2009

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


Session processing degrades the performance greatly - El Forum - 05-04-2009

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


Session processing degrades the performance greatly - El Forum - 05-04-2009

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


Session processing degrades the performance greatly - El Forum - 05-04-2009

[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();
        }
    }
}
?>