Welcome Guest, Not a member yet? Register   Sign In
Object in session in MY_Controller clears the session completely.
#3

[eluser]dakipro[/eluser]
Thanks, I checked the size and changed the database field for user_data to be longtext, still same issue. Session gets cleared the moment I add this object to the session, here is dump of the session

Code:
dump ($this->session) - File:  E:\www\application\controllers\admin\pages.php, line: 92;
stdClass Object
(
    [__CLASS__] => CI_Session
    [sess_encrypt_cookie] =>
    [sess_use_database] => 1
    [sess_table_name] => ci_sessions
    [sess_expiration] => 7200
    [sess_expire_on_close] =>
    [sess_match_ip] =>
    [sess_match_useragent] => 1
    [sess_cookie_name] => ci_session
    [cookie_prefix] =>
    [cookie_path] => /
    [cookie_domain] =>
    [cookie_secure] =>
    [sess_time_to_update] => 300
    [encryption_key] => CODETMP
    [flashdata_key] => flash
    [time_reference] => local
    [gc_probability] => 5
    [userdata] => Array
        (
            [session_id] => b5638e7c14d7e4d3766e427dcf3ad6d9
            [ip_address] => 127.0.0.1
            [user_agent] => Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0.1) Geck
            [last_activity] => 1305577013
            [languagesActive] => Array
                (
                    [languages_default] => stdClass Object
                        (
                            [__CLASS__] => models\Language
                            [id] => 2
                            [lang_name] => English
                            [lang_ext] => en
                            [ordering] => 2
                            [is_active] => 1
                            [is_default] => 1
                            [is_deletable] => 1
                            [field_rules] => Array
                                (
                                )

                            [prePersistDefaults] => Array
                                (
                                )

                            [mainObjName] => models\Language
                            [defaultSortingField] => ordering
                            [paginateResults] =>
                            [paginationLinksCreated] =>
                            [paginationConfig] =>
                            [qb] =>
                        )

                )

            [FlashNotice] => Array
                (
                    [info] => Array
                        (
                        )

                    [success] => Array
                        (
                        )

                    [warning] => Array
                        (
                        )

                    [error] => Array
                        (
                            [0] => validation_errors()
                            [1] => item_not_found_for_editing
                        )

                )

        )

    [CI] => stdClass Object
        (
            [__CLASS__] => Pages
            [mainObjName] => models\Page
        )

    [now] => 1305577038
)

After this is set in session, the moment redirection is done the entire part
Code:
[FlashNotice] => Array(
...
gets lost. This happens with flash_data as well, it gets lost if in MY_Controller __construct() I put this line
Code:
$laguagesData = array(
            'languages_default'=> $this->doctrine->em->getRepository('models\Language')->findBy(array('is_active'=>1))
        );
//this uses doctrine to get the object, its dump is visible in code I pasted above, it doesn't matter as it fails if I create plain object like
// 'languages_default'=> new models\Language();
$this->session->set_userdata('languagesActive',$laguagesData);

Again, if I remove this line from MY_Controller, or if I put this line
Code:
$laguagesData = array(
            'languages_default'=> 'Whatever string I want to put here'
        );
all works fine, session is preserved and this code exists on the next page
Code:
[FlashNotice] => Array
                (

After the old data is lost, I can confirm that session ID changes as well.

Here is the sample session cookie dump set in the browser
Code:
a:4:{s:10:"session_id";s:32:"c4297d0a493432155fb361828078c9a1";s:10:"ip_address";s:9:"127.0.0.1";s:10:"user_agent";s:50:"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0.1) Geck";s:13:"last_activity";i:1305577882;}fe3a99b94d7f4937d5edc6b335bfde18
//Note that this is not exact the same cookie from the dump above, but it is for the same code


Messages In This Thread
Object in session in MY_Controller clears the session completely. - by El Forum - 05-16-2011, 02:37 PM



Theme © iAndrew 2016 - Forum software by © MyBB