unserialize() error?

It was all ok but when I refresh a page it suddenly encountered this error:

unserialize(): Error at offset 5 of 92 byte

below is the log


C:\htdocs\Yii\framework\base\CStatePersister.php(96)


084             $cacheKey=\'Yii.CStatePersister.\'.$stateFile;

085             if(($value=$cache->get($cacheKey))!==false)

086                 return unserialize($value);

087             else if(($content=@file_get_contents($stateFile))!==false)

088             {

089                 $cache->set($cacheKey,$content,0,new CFileCacheDependency($stateFile));

090                 return unserialize($content);

091             }

092             else

093                 return null;

094         }

095         else if(($content=@file_get_contents($stateFile))!==false)

096             return unserialize($content);

097         else

098             return null;

099     }

100 

101     /**

102      * Saves application state in persistent storage.

103      * @param mixed $state state data (must be serializable).

104      */

105     public function save($state)

106     {

107         file_put_contents($this->stateFile,serialize($state),LOCK_EX);

108     }

Stack Trace


#0	

+  C:\htdocs\Yii\framework\base\CStatePersister.php(96): unserialize("a:1:{s:34:\"Yii.CSecurityManager.validationkey\";s:32:\"6334523f...")

#1	

+  C:\htdocs\Yii\framework\base\CApplication.php(573): CStatePersister->load()

#2	

+  C:\htdocs\Yii\framework\base\CApplication.php(513): CApplication->loadGlobalState()

#3	

+  C:\htdocs\Yii\framework\base\CSecurityManager.php(88): CApplication->getGlobalState("Yii.CSecurityManager.validationkey")

#4	

+  C:\htdocs\Yii\framework\base\CSecurityManager.php(269): CSecurityManager->getValidationKey()

#5	

+  C:\htdocs\Yii\framework\base\CSecurityManager.php(249): CSecurityManager->computeHMAC("test")

#6	

+  C:\htdocs\Yii\framework\web\auth\CWebUser.php(420): CSecurityManager->validateData("a0c37fb989643204e0c8754ac81e6bcbbaca28faa:4:{i:0;s:1:"1";i:1;s:1...")

#7	

+  C:\htdocs\Yii\framework\web\auth\CWebUser.php(181): CWebUser->restoreFromCookie()

#8	

+  C:\htdocs\Yii\framework\base\CModule.php(372): CWebUser->init()

#9	

+  C:\htdocs\Yii\framework\web\CWebApplication.php(189): CModule->getComponent("user")

#10	

+  C:\htdocs\Yii\framework\web\auth\CAccessControlFilter.php(109): CWebApplication->getUser()

#11	

+  C:\htdocs\Yii\framework\web\filters\CFilter.php(39): CAccessControlFilter->preFilter(CFilterChain)

#12	

+  C:\htdocs\Yii\framework\web\CController.php(1122): CFilter->filter(CFilterChain)

#13	

+  C:\htdocs\Yii\framework\web\filters\CInlineFilter.php(59): CController->filterAccessControl(CFilterChain)

#14	

+  C:\htdocs\Yii\framework\web\filters\CFilterChain.php(130): CInlineFilter->filter(CFilterChain)

#15	

+  C:\htdocs\Yii\framework\web\CController.php(283): CFilterChain->run()

#16	

+  C:\htdocs\Yii\framework\web\CController.php(257): CController->runActionWithFilters(CInlineAction, array("accessControl"))

#17	

+  C:\htdocs\Yii\framework\web\CWebApplication.php(328): CController->run("view")

#18	

+  C:\htdocs\Yii\framework\web\CWebApplication.php(121): CWebApplication->runController("book/view")

#19	

+  C:\htdocs\Yii\framework\base\CApplication.php(155): CWebApplication->processRequest()

#20	

–  C:\htdocs\test1\index.php(12): CApplication->run()

07 // remove the following lines when in production mode

08 defined(\'YII_DEBUG\') or define(\'YII_DEBUG\',true);

09 defined(\'YII_TRACE_LEVEL\') or define(\'YII_TRACE_LEVEL\',3);

10 

11 require_once($yii);

12 Yii::createWebApplication($config)->run();

2011-06-10 16:23:41 Apache/2.2.17 (Win32) PHP/5.3.5 Yii Framework/1.1.7

What’s wrong?

I think it’s an session error. It runs well if i use another browser.

I think you should check the character encoding of your session db table.

That’s definitely not the reason, because I used to use C:/temp to save session as files.

Now I config session autostart to be false and use my own session class trying to save it in the database but it still get the same problem in Chrome(Other browsers work well) I don’t know whether it is because of there are something wrong with my php.ini or error in my own session class.

I tried to use CDbSession and when I chose ‘remember me’ I encounter that problem again.

Setting ‘magic_quote_runtime’ in php.ini to be ‘Off’ solves this problem.

It is already off and still setting error

PHP Notice – yii\base\ErrorException
unserialize(): Error at offset 72 of 65535 bytes