Welcome Guest, Not a member yet? Register   Sign In
Session creates new session id on every page load
#21

[eluser]benharrison[/eluser]
base_url() works as expected. I have been using XAMPP lite for development, and a Dreamhost shared hosting plan (which I believe is Apache) for staging. Thanks for your help. I will look into the other possibilities further.
#22

[eluser]PHPexpert[/eluser]
Would be possible for you to disable CodeIgniter session variable in the config file and instead use the native php sessions and see if you still have the same problem. Please let use know.
#23

[eluser]WanWizard[/eluser]
Detecting where the problem is, so it can be solved, should be a 10 minute job.

Not really the moment to rework the code just yet (my 2ct...).
#24

[eluser]Mr-H[/eluser]
hi a had this probleme to, it seems that the session class creat each time you load the page "that containt a flash " a hashed md5 session_id, to prevent this in youre config.php look for $config['sess_match_ip'] = FALSE;
and replace with:
$config['sess_match_ip'] = TRUE;
that all, hope it will help you...
sorry my english
#25

[eluser]Mr-H[/eluser]
another solution but is not allowed you to browse you website on all browser(google chrom, firefox,safari...)
in phpmyadmin in the ci_session table creat a UNIQUE key for the ip_address
#26

[eluser]Abdul Jamal[/eluser]
Please save this file system\application\libraries named "Session.php" now check

Code:
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');


class CI_Session {

    var $flash_key = 'flash'; // prefix for "flash" variables (eg. flash:new:message)

    function CI_Session()
    {
        $this->object =& get_instance();
        log_message('debug', "Native_session Class Initialized");
        $this->_sess_run();
    }


    function regenerate_id()
    {
        // copy old session data, including its id
        $old_session_id = session_id();
        $old_session_data = $_SESSION;

        // regenerate session id and store it
        session_regenerate_id();
        $new_session_id = session_id();

        // switch to the old session and destroy its storage
        session_id($old_session_id);
        session_destroy();

        // switch back to the new session id and send the cookie
        session_id($new_session_id);
        session_start();

        // restore the old session data into the new session
        $_SESSION = $old_session_data;

        // update the session creation time
        $_SESSION['regenerated'] = time();

        // session_write_close() patch based on this thread
        // http://www.ellislab.com/forums/viewthread/1624/
        // there is a question mark ?? as to side affects

        // end the current session and store session data.
        session_write_close();
    }


    function destroy()
    {
        unset($_SESSION);
        if ( isset( $_COOKIE[session_name()] ) )
        {
            setcookie(session_name(), '', time()-42000, '/');
        }
        session_destroy();
    }

  
    function userdata($item)
    {
        if($item == 'session_id'){ //added for backward-compatibility
            return session_id();
        }else{
            return ( ! isset($_SESSION[$item])) ? false : $_SESSION[$item];
        }
    }


    function set_userdata($newdata = array(), $newval = '')
    {
        if (is_string($newdata))
        {
            $newdata = array($newdata => $newval);
        }

        if (count($newdata) > 0)
        {
            foreach ($newdata as $key => $val)
            {
                $_SESSION[$key] = $val;
            }
        }
    }


    function unset_userdata($newdata = array())
    {
        if (is_string($newdata))
        {
            $newdata = array($newdata => '');
        }

        if (count($newdata) > 0)
        {
            foreach ($newdata as $key => $val)
            {
                unset($_SESSION[$key]);
            }
        }
    }


    function _sess_run()
    {
        session_start();

        $session_id_ttl = $this->object->config->item('sess_expiration');

        if (is_numeric($session_id_ttl))
        {
            if ($session_id_ttl > 0)
            {
                $this->session_id_ttl = $this->object->config->item('sess_expiration');
            }
            else
            {
                $this->session_id_ttl = (60*60*24*365*2);
            }
        }

        // check if session id needs regeneration
        if ( $this->_session_id_expired() )
        {
            // regenerate session id (session data stays the
            // same, but old session storage is destroyed)
            $this->regenerate_id();
        }

        // delete old flashdata (from last request)
        $this->_flashdata_sweep();

        // mark all new flashdata as old (data will be deleted before next request)
        $this->_flashdata_mark();
    }


    function _session_id_expired()
    {
        if ( !isset( $_SESSION['regenerated'] ) )
        {
            $_SESSION['regenerated'] = time();
            return false;
        }

        $expiry_time = time() - $this->session_id_ttl;

        if ( $_SESSION['regenerated'] <=  $expiry_time )
        {
            return true;
        }

        return false;
    }


    function set_flashdata($key, $value)
    {
        $flash_key = $this->flash_key.':new:'.$key;
        $this->set_userdata($flash_key, $value);
    }


    function keep_flashdata($key)
    {
        $old_flash_key = $this->flash_key.':old:'.$key;
        $value = $this->userdata($old_flash_key);

        $new_flash_key = $this->flash_key.':new:'.$key;
        $this->set_userdata($new_flash_key, $value);
    }

    function flashdata($key)
    {
        $flash_key = $this->flash_key.':old:'.$key;
        return $this->userdata($flash_key);
    }


    function _flashdata_mark()
    {
        foreach ($_SESSION as $name => $value)
        {
            $parts = explode(':new:', $name);
            if (is_array($parts) && count($parts) == 2)
            {
                $new_name = $this->flash_key.':old:'.$parts[1];
                $this->set_userdata($new_name, $value);
                $this->unset_userdata($name);
            }
        }
    }

    
    function _flashdata_sweep()
    {
        foreach ($_SESSION as $name => $value)
        {
            $parts = explode(':old:', $name);
            if (is_array($parts) && count($parts) == 2 && $parts[0] == $this->flash_key)
            {
                $this->unset_userdata($name);
            }
        }
    }
}
?&gt;
#27

[eluser]Lockzi[/eluser]
I have the exact same problem as the people above.

Database sessions.

New database row for each page load.

All config variables should be allright,
gonna start the debugging now.

I'll get back with results!
#28

[eluser]Lockzi[/eluser]
Current settings in config.php

Code:
$config['base_url']    = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '').'://'.$_SERVER['HTTP_HOST'];

$config['sess_cookie_name']    = 'ci_session';
$config['sess_expiration']    = 7200;
$config['sess_encrypt_cookie']    = true;
$config['sess_use_database']    = true;
$config['sess_table_name']    = 'interface_ci_sessions';
$config['sess_match_ip']    = true;
$config['sess_match_useragent']    = true;
$config['sess_time_to_update']     = 300;


$config['cookie_prefix']    = "auInterface";
$config['cookie_domain']    = $config['base_url'];
$config['cookie_path']        = "/";

Firefox webdeveloper add-on tells me no cookie for this website.

I've tried setting match_ip as well as useragent to false, still no luck. New database row for each page refresh.

This problem occurs on a server that is not local, so an external domain is used for access. (No localhost problems)

When using the application/libraries/Session.php file I do get a cookie (according to webdeveloper), but nothing is stored in the database.

The session data also works with the Native_session Class.
Any ideas on how to proceed?

Thanks,
Lockzi
#29

[eluser]WanWizard[/eluser]
Check with firebug or Live HTTP headers if the HTTP header of the request result contains a cookie, and if so, what it's definition is (domain and path ok, expiration time ok?).

Also, remove the underscore from the cookie_name, some browsers don't like that.
#30

[eluser]Lockzi[/eluser]
Here's the results...

Removed the CI_Native session library, and deleteted the cookie belonging to that.

Upon ran fresh (without any cookies belonging to this domain):

Code:
Date    Thu, 14 Oct 2010 08:25:24 GMT
Server    Apache/2.2.8 (Ubuntu) DAV/2 SVN/1.4.6 mod_python/3.3.1 Python/2.5.2 PHP/5.2.4-2ubuntu5.12 with Suhosin-Patch mod_ruby/1.2.6 Ruby/1.8.6(2007-09-24) mod_ssl/2.2.8 OpenSSL/0.9.8g mod_wsgi/1.3
X-Powered-By    PHP/5.2.4-2ubuntu5.12
Set-Cookie    auInterfaceci_session=X12wN32khmaaAV6a+c9LW/O/QZ7rSvAzONIrlDBW7C9JAlcXZxhRuQUu54CHil1CDtTNFFs8X9+08IBIQOF95ix6dtSEgVyz3riLJFC1vSB6HBNS7z3XfScfccQbwV84z8XX3fe2XU5aW9KeXXADBBoViVv6BsGUfow9erXzEw2ri7LfLbjdOKiBJdwJwBQC1sgXRMK58c40NnIkYz+kBXS+xOPYc5KYduWBWGK3sODc+E0afhgsYcSSTvmTGPriOfpuHlC1iCdb6KAFvZHqVRIWdKAzKrJELR4WtP1VZu+BQT2qzRq1lBl7IVBnU7noV81d/kYVYrYqhyohE9A9nkpH8OsCl5nBqH3LYSIHG8vV22dplK+aA6N8Jmc3zRxi3lgv7kC3lGIJF7RwBsZ15TCZyAWyWYythqiHKEvznVCvTFs+Qi275zJf11A1NvXwbeu2JNqTSVhkSNdt9rlu78uBCdc5GFv3xCjpqLtOQH1RcXTJsisNYcaMhZ3IqkbUFpt1pS0rfD+hJi+2Ys2g2pMyoa9VWDFJZw7FaRNYA5IUVhBCJNZF3oVVm4C9gI6Xnr93u/wQe560TUqjaAXNF1t5ZkPhOwc8eThM1Q+NZXEH7zghBr6bK6fXe1GW/EPG; expires=Thu, 14-Oct-2010 10:25:24 GMT; path=/; domain=http://subdomain.domain.se auInterfaceci_session=IwfiisI0gBufEI+PCkLE/6mT55m9f9uk71ZMiApp7qBol8qp1D7u2cF21igiJ40fKzPgRSqRSXvPVvjQjEV/G5FnKKLHz3xqmRbUiHWU8i6+2K37fGk/119UOSDIeAnKGryVAOZmilZfcXsKUPoZRQCV0sKTM2vnJucAVnkPY5YJOlISfT0g1Ck9dx/heGe7vIMElesy+ldbhdyQ13g5levrN2YpRhnmKKQPdI2elL20cXTVwXZNmkYQkRBW76UM9VYV4DSQsh+2+F2cLjQdMjOMTyo8iwP9rReocbnQgqfZrSn8HFJ3vnWettv8rG5tjoYgXvYNAEnPPUOb93jRQoF//W1z8foz0tN9CdlxPLeQCowmK4txAf2ZxNBU1NHGa7gCEry7QfcSNtIWnE1+b2qeA0PlFCLktKolV27eGWDF/MnL4jzK8LVJX79/IgOP9kFqpdz6ji9zjdOvWERPGpLWm8VFdqvOcdw1cJoaQIXcCbXu7fRvvgGBt7znVW80DaWW4Eeyu3r3pG+k/8AJU9SxcXT9NBySdb4FRvii5pmR+Q990vKb0OfemyM06CTRYp9jiEkY8O70eNFhKOEdxLImf9trpUoYy/TlS6Y3c9xKidHV1rVKGElUT5tc/Pm7; expires=Thu, 14-Oct-2010 10:25:24 GMT; path=/; domain=http://subdomain.domain.se auInterfaceci_session=wM5jWTmPrbkv2WdRPfAf5xkMgCLHS2tkjnvCTov8OW00obLydZZqwFXno8ldjYHrCyCH2RXYsVr8lNe7sxZ8XIOK3g1HKA3MBf6QFYVM8lNGo6v46uZMHBvGlrChq4K4P9yTjhmRYeiol0EG0zuTXYPPz1GlikZmuGGafNVKxMuvL3ieJ774pxKTVaW4ONog3SmDhw9Hzmn4i8LsmU1JkLVyOf2VJAGSp6d4edlCppzEmhAM03xtRTdlSQ0KCDWyV138MT1t26Epg3eTQOwOsB8AQNRTmglW3Iqvv3LJyk0+ud4eGV+IgsHSvZcW1ShJhXKbNfgv6kl2RRC+UaIgOOr+supLZL+Ch3nK0AmP8cAZvm4RcxlX72oQh2FwhoYepGRvJmmY2RNImoB4tT1g6F9bXYPw2+7HriwiTpbE72JI0/toofqTaISSvdG9J3vMngw5/mEQDO6Of6wU+GkasQekWMIDUu51VGDf2qhS9E2aO05iT7UeRtqaXe9zRUh6ahZOMhEjsfopa3nV88jqu/f4CJExWNelK7XGkidU+z6cORZZ07VqLkv6QrsjCpLdkusbM0f1miVNN937PFZo/FAonCAhSXjtApV8Cz4URwWdJJhbcF2yP8PPBHVKIRei; expires=Thu, 14-Oct-2010 10:25:24 GMT; path=/; domain=http://subdomain.domain.se auInterfaceci_session=8P/fkSeA+s5bUWjooZ+ibYNk2Zm1UrtnNVGBMu1QGWZqLnlsQO2rQJXsuk1pd2AIoNK/nm6wFwSAr9+S5XzbNMEVpiLj5dz2oDgF0BNBwY4IJjw93ExOtmQYqL56FfYKO/Bdg9MDnuXwxsbI7IKSr32osOKXidUvn1PLl/BrRvfDMYGfu/K8IGlx+GL1bWU8mAYSJb30Kgk72JxoqpozA4XyvdWZR92Rsg8zS6HtanFxX018aVGpeKn7TpIjaRyB011jPi+nlgMiPWiDD/7hoc3CuBJ/vIawCv9n2Exsg5+ky74Tc/HVDtQmvXRVXTxhph9u/EGEdGeqmU7q0X5TKvlxXSBJuDtMfrw60ZnrZ4stRBy4RdNEsm1r++U/FUfTyM4+MwKKhkeZHjJ+DLcNJ/Oc6psm8nZ7e+GpBfS+xgWtxvk7bjcVBGXkhVNkglbbZn4twjh76oLUEAVJ6I5wJsj1p3PuJz2cjvWpXnqzZ+5cGqn/qjVohG0X44tqGxayUqUcKWZ2kSvD9DYF/IDP6XgqUYW5LUWc7IqEMZMY6oQo2T1ut5V9o1vF1GWLf5jJ2bMZe6uDox6xc4rZQRgb0bt3zB3Dn4IWnD0DMNKaZl11BS9z7jKnlx4lCB+j4AWW; expires=Thu, 14-Oct-2010 10:25:24 GMT; path=/; domain=http://subdomain.domain.se
Keep-Alive    timeout=15, max=100
Connection    Keep-Alive
Transfer-Encoding    chunked
Content-Type    text/html
Accept-Ranges    none

You said to remove the undersocre in the cookie, where's that underscore? :S

Also, http://subdomain.domain.se is the replacement of my corresponding real domain.




Theme © iAndrew 2016 - Forum software by © MyBB