Welcome Guest, Not a member yet? Register   Sign In
IE + Hybrid Session = Fail


I wrote an app, I have check it on IE and it dont work, app uses Session so I do some research on google and find out this Hybrid Session library, so I inserted in system/application/libraries and name it Session.php, I also created a table in db for that purpose, describtion from postgresql which I use normally:
Quote:\d ci_sessions
Table "public.ci_sessions"
Column | Type | Modifiers
session_id | character varying(32) | not null default ''::character varying
user_agent | character varying(255) | default NULL::character varying
ip_address | character varying(20) | default NULL::character varying
last_activity | integer |
user_data | text |
"ci_sessions_pkey" PRIMARY KEY, btree (session_id)

Part of config file responsible for the session:
$config['sess_cookie_name']             = 'ci_session';
$config['sess_expiration']              = 1800;
$config['sess_encrypt_cookie']  = TRUE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']              = 'ci_sessions';
$config['sess_match_ip']                = TRUE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update']  = 300;

And the code of my simple test app:

class Lol extends Controller {
        function lol(){
        function delete_sessiona()
                echo anchor('lol/echo_sessiona','Echo msg').'<br>';
                echo anchor('lol/set_sessiona', 'Set Msg');

//              $this->session->sess_destroy();


function set_sessiona(){
                $this->session->set_userdata('test', 'Test msg');
                echo anchor('lol/delete_sessiona','Delete msg').'<br>';
                echo anchor('lol/echo_sessiona' ,'ECho msg');
function echo_sessiona()
        echo $this->session->userdata('test');
        echo anchor('lol/delete_sessiona','Delete msg').'<br>';
        echo anchor('lol/set_sessiona', 'Set Msg');

And the problem, on chrome and mozilla, every thing works fine but on IE it works like this, every time I try to set data i get new row in table with some user_data info, every time I try to echo the msg I get new row in table with new session_id and with no user_data info.

Can some one help me?

I have even changed part of code from this thread:


but it wont work anyways :/.

Make sure your cookie config is ok too (domain, path, etc). Make also sure the domain doesn't contain an underscore.

What do you mean by cookie config? This:
$config['cookie_prefix']        = "";
$config['cookie_domain']        = "";
$config['cookie_path']          = "/";
what should i put in there ?
domain = http://app.my-domain.com/ ?
and what about path and prefix ?

domain is normally either your domain ('my-domain.com'), or the host itself ('app.my-domain.com'), depending on how you want your cookies to be accessable.
path is normally a slash, unless you installed your app in a subdirectory of the docroot.

Ok, so here is the thing, my app is on linux server in dir like this:
/var/www/my_app, but in cookie config I leave path unchanged,
second thing is domain and tell me something why I have to put it twice, once in $config['base_url'] and second time in $config['cookie_domain']? It works for now but I dont like it, I keep many data in session, and almost on every click on my web-app I get query for db because some info is in session :/.

And at the end of this whole mess, my login function dont work on any browser, maybe it's because I'm using session_id to hash :/.

Anyways, thanks for helping me out, is there any info about new CI release with session lib working properly without need of db using for it ?

It is separate because they are two different things.

base_url can be something like "http://www.example.org/my/sub/dir", your cookie domain might be ""http://www.example.org/my/sub", and the path "/", allowing all applications in "my/sub" to share the same cookies.

And don't blame CI for the mess, you're the programmer, you should have build something that works in all circumstances, and that starts with proper planning and design.

If you don't want to use the database for session info (why not?), you will have to resort to file based storage, like the standard PHP session handling. In which case I can't help you any further, I use database sessions, and that works fine here.

Ok, every thing is fine, but what about left overs? how to clean that table in db? And what about the load of the db if the app is used very often? My app is almost on every click changed the state of session and I cant clean the session at the end of loading function.

Any ideas ?

Normally a session stays valid for (as the name implies), the time the user has a connection with the application. CI will take care of session_id renewal on a regular basis. Adding or deleting session values doesn't produce extra records, it's one record per session.

Like any session engine CI's session library also has builtin garbage collection for sessions that are not destroyed, controlled by the session class variable gc_probability (default value is 5%).

I have a site running with more than 15.000 users, all quite active. And I have no problem whatsoever with the performance of the session library.

Ok, that's all Smile.

Thanks for help WanWizard Smile.


Theme © iAndrew 2016 - Forum software by © MyBB