- Posts: 3
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Error storing the session in table session in SQL Server DB. LimeSurvey 2.05
- iasneaj
- Topic Author
- Offline
- New Member
I uncomment these lines in the application/config/config.php to store the user session's in database
/ Uncomment the following line if you need table-based sessions 'session' => array ( 'class' => 'system.web.CDbHttpSession', 'connectionID' => 'db', 'sessionTableName' => '{{sessions}}', ),
but when a user try to answer a survey (closed survey, with no anoymous users) we saw this error in the application and the user can't complete the survey, because he has no session stored in DB
CDbCommand failed to execute the SQL statement: CDbCommand failed to prepare the SQL statement: SQLSTATE[IMSSP]: An error occurred substituting the named parameters.. The SQL statement executed was: UPDATE [lime_sessions] SET [data]=CONVERT(VARBINARY(MAX), 'adminlang|s:2:"es";LEMsid|s:6:"436179";survey_436179|a:25:{s:6:"s_lang";s:2:"es";s:6:"refurl";s:90:" pruebasenquestasexternaspre.lacaixa.es/i...up_name";s:13:"Grupo de test";s:11:"description";s:0:"";}}s:14:"totalquestions";i:1;s:10:"totalsteps";i:1;s:5:"token";s:15:"d9fj2e9k6ac4rxn";s:11:"insertarray";a:2:{i:0;s:5:"token";i:1;s:17:"436179X1414X54480";}s:10:"groupReMap";a:0:{}s:8:"fieldmap";a:6:{s:2:"id";a:9:{s:9:"fieldname";s:2:"id";s:3:"sid";s:6:"436179";s:4:"type";s:2:"id";s:3:"gid";s:0:"";s:3:"qid";s:0:"";s:3:"aid";s:0:"";s:5:"title";s:0:"";s:8:"question";s:15:"ID de respuesta";s:10:"group_name";s:0:"";}s:10:"submitdate";a:9:{s:9:"fieldname";s:10:"submitdate";s:4:"type";s:10:"submitdate";s:3:"sid";s:6:"436179";s:3:"gid";s:0:"";s:3:"qid";s:0:"";s:3:"aid";s:0:"";s:5:"title";s:0:"";s:8:"question";s:15:"Fecha de envío";s:10:"group_name";s:0:"";}s:8:"lastpage";a:9:{s:9:"fieldname";s:8:"lastpage";s:3:"sid";s:6:"436179";s:4:"type";s:8:"lastpage";s:3:"gid";s:0:"";s:3:"qid";s:0:"";s:3:"aid";s:0:"";s:5:"title";s:0:"";s:8:"question";s:15:"Última página";s:10:"group_name";s:0:"";}s:13:"startlanguage";a:9:{s:9:"fieldname";s:13:"startlanguage";s:3:"sid";s:6:"436179";s:4:"type";s:13:"startlanguage";s:3:"gid";s:0:"";s:3:"qid";s:0:"";s:3:"aid";s:0:"";s:5:"title";s:0:"";s:8:"question";s:16:"Lenguaje inicial";s:10:"group_name";s:0:"";}s:5:"token";a:9:{s:9:"fieldname";s:5:"token";s:3:"sid";s:6:"436179";s:4:"type";s:5:"token";s:3:"gid";s:0:"";s:3:"qid";s:0:"";s:3:"aid";s:0:"";s:5:"title";s:0:"";s:8:"question";s:11:"Contraseña";s:10:"group_name";s:0:"";}s:17:"436179X1414X54480";a:19:{s:9:"fieldname";s:17:"436179X1414X54480";s:4:"type";s:1:"T";s:3:"sid";s:6:"436179";s:3:"gid";s:4:"1414";s:3:"qid";s:5:"54480";s:3:"aid";s:0:"";s:5:"title";s:6:"SQ0001";s:8:"question";s:10:" Question";s:10:"group_name";s:13:"Grupo de test";s:9:"mandatory";s:1:"N";s:13:"hasconditions";s:1:"N";s:16:"usedinconditions";s:1:"N";s:11:"questionSeq";i:0;s:8:"groupSeq";i:0;s:9:"relevance";s:1:"1";s:10:"grelevance";s:0:"";s:4:"preg";s:0:"";s:5:"other";s:1:"N";s:4:"help";s:0:"";}}s:10:"fieldarray";a:1:{i:0;a:9:{i:0;s:5:"54480";i:1;s:17:"436179X1414X54480";i:2;s:6:"SQ0001";i:3;s:10:" Question";i:4;s:1:"T";i:5;s:4:"1414";i:6;s:1:"N";i:7;s:1:"N";i:8;s:1:"N";}}s:14:"startingValues";a:0:{}s:13:"LEMdebugLevel";i:0;s:4:"step";i:1;s:7:"maxstep";i:1;s:8:"prevstep";i:0;s:4:"test";i:1479316833;s:10:"LEMpostKey";i:560380404;s:15:"relevanceStatus";a:2:{i:54480;b:1;s:2:"G0";i:1;}s:17:"436179X1414X54480";N;s:9:"datestamp";s:19:"2016-11-16 18:20:37";s:4:"srid";s:1:"1";s:6:"stepno";i:1;}LEMlang|s:2:"es";fieldmap-436179es|a:6:{s:2:"id";a:9:{s:9:"fieldname";s:2:"id";s:3:"sid";s:6:"436179";s:4:"type";s:2:"id";s:3:"gid";s:0:"";s:3:"qid";s:0:"";s:3:"aid";s:0:"";s:5:"title";s:0:"";s:8:"question";s:15:"ID de respuesta";s:10:"group_name";s:0:"";}s:10:"submitdate";a:9:{s:9:"fieldname";s:10:"submitdate";s:4:"type";s:10:"submitdate";s:3:"sid";s:6:"436179";s:3:"gid";s:0:"";s:3:"qid";s:0:"";s:3:"aid";s:0:"";s:5:"title";s:0:"";s:8:"question";s:15:"Fecha de envío";s:10:"group_name";s:0:"";}s:8:"lastpage";a:9:{s:9:"fieldname";s:8:"lastpage";s:3:"sid";s:6:"436179";s:4:"type";s:8:"lastpage";s:3:"gid";s:0:"";s:3:"qid";s:0:"";s:3:"aid";s:0:"";s:5:"title";s:0:"";s:8:"question";s:15:"Última página";s:10:"group_name";s:0:"";}s:13:"startlanguage";a:9:{s:9:"fieldname";s:13:"startlanguage";s:3:"sid";s:6:"436179";s:4:"type";s:13:"startlanguage";s:3:"gid";s:0:"";s:3:"qid";s:0:"";s:3:"aid";s:0:"";s:5:"title";s:0:"";s:8:"question";s:16:"Lenguaje inicial";s:10:"group_name";s:0:"";}s:5:"token";a:9:{s:9:"fieldname";s:5:"token";s:3:"sid";s:6:"436179";s:4:"type";s:5:"token";s:3:"gid";s:0:"";s:3:"qid";s:0:"";s:3:"aid";s:0:"";s:5:"title";s:0:"";s:8:"question";s:11:"Contraseña";s:10:"group_name";s:0:"";}s:17:"436179X1414X54480";a:19:{s:9:"fieldname";s:17:"436179X1414X54480";s:4:"type";s:1:"T";s:3:"sid";s:6:"436179";s:3:"gid";s:4:"1414";s:3:"qid";s:5:"54480";s:3:"aid";s:0:"";s:5:"title";s:6:"SQ0001";s:8:"question";s:10:" Question";s:10:"group_name";s:13:"Grupo de test";s:9:"mandatory";s:1:"N";s:13:"hasconditions";s:1:"N";s:16:"usedinconditions";s:1:"N";s:11:"questionSeq";i:0;s:8:"groupSeq";i:0;s:9:"relevance";s:1:"1";s:10:"grelevance";s:0:"";s:4:"preg";s:0:"";s:5:"other";s:1:"N";s:4:"help";s:0:"";}}LEMsingleton|s:52062:"O:21:"LimeExpressionManager":52:{s:25:"'???l?l??y6Cj?k??88?l@), [expire]=:expire WHERE id=:id. Bound with :id='jddd92sclc743130j15a1vhc85', :expire=1479324038
We have Limesurvey 2.05+ build 150310 version installed in the following stack platform:
- OS: Windows Server 2012 R2
- Web Server: Internet Information Server 8.5
- PHP version: 5.6.7
- Database: SQL Server 2012 in Windwows Server 2012 R2
I searched through the code of this LimeSurvey version and I came to the framework/web/CdbHttpSession.php file, function writeSession.
In this function there's an if to check the database installed in the environment an then use the CDbExpression to all of the database supported.
public function writeSession($id,$data) { // exception must be caught in session write handler // http://us.php.net/manual/en/function.session-set-save-handler.php try { $expire=time()+$this->getTimeout(); $db=$this->getDbConnection(); if($db->getDriverName()=='sqlsrv' || $db->getDriverName()=='mssql' || $db->getDriverName()=='dblib') $data=new CDbExpression('CONVERT(VARBINARY(MAX), '.$db->quoteValue($data).')'); if($db->createCommand()->select('id')->from($this->sessionTableName)->where('id=:id',array(':id'=>$id))->queryScalar()===false) $db->createCommand()->insert($this->sessionTableName,array( 'id'=>$id, 'data'=>$data, 'expire'=>$expire, )); else $db->createCommand()->update($this->sessionTableName,array( 'data'=>$data, 'expire'=>$expire ),'id=:id',array(':id'=>$id)); } catch(Exception $e) { if(YII_DEBUG) echo $e->getMessage(); // it is too late to log an error message here return false; } return true; }
In my local enviroment i have installed LimeSurvey in a LAMP stack with version 2.55+ build 161021 and I see no problem storing the user's session in the 'sessions' table.
I'm not overly confident with SQL Server but, do you think that there's any problem with this SQL command in my database version? or , it could be a bug in the LimeSurvey code with SQL Server 2012 as database?
Do you have any advice to solve this problem?
Thanks
Kind regards
- DenisChenu
- Offline
- LimeSurvey Community Team
- Posts: 13647
- Thank you received: 2491
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
- LouisGac
- Visitor
Please, update.
- iasneaj
- Topic Author
- Offline
- New Member
- Posts: 3
- Thank you received: 0
Thanks for the quick response, Denis and Louis.
I din't check properly the changelog in the 2.0.6 lts and 2.50 branch. My fault, sorry for the inconvenience.
I will try to convince the user's to update to the 2.0.6 lts or 2.50.
Kind regards.