Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Error: Bad Request, CSRF Token

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 11 months ago - 9 years 11 months ago #107147 by DenisChenu
Replied by DenisChenu on topic Error: Bad Request, CSRF Token
I try myself with:
Code:
php_value session.cookie_domain ".sondages.pro"
But without any other modification, LimeSurvey work great too.

But YII_CRSF cookie is set for limesurvey.sondages.pro.
I think there another restriction for all your cookie, not only your session cookie.

You can set your crsf cookie domain too. Try this in config.php
Code:
'request' => array(
            'csrfCookie' => array( 'domain' => '.sciences-po.fr' )
        ),
(I think you can leave the session cookie to .sciences-po.fr. I don't know what happend for 'Time' cookie.

If you have more information on your server, and why cookie with subdomain can not be set. Maybe you have another Yii elsewhere ?

Denis

PS: last chance: update internal.php
Code:
'enableCsrfValidation'=>false,    // CSRF protection

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.
Last edit: 9 years 11 months ago by DenisChenu.
The topic has been locked.
  • zobbyzobba
  • zobbyzobba's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 11 months ago #107236 by zobbyzobba
Replied by zobbyzobba on topic Error: Bad Request, CSRF Token
Hi,

Forcing CSRF domain not help :(

Deactivation of CSRF give me an error page which said that my session is expired, all the time. Even if my cookie cache is cleared.

If you have more information on your server, and why cookie with subdomain can not be set. Maybe you have another Yii elsewhere ?


My server is running Apache 2.2 with PHP 5.5.9, I don't have other Yii applications, but I have a Piwik and a personal PHP site which are working great and use PHP sessions and cookies like Limesurvey.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 11 months ago #107320 by DenisChenu
Replied by DenisChenu on topic Error: Bad Request, CSRF Token
I test with 2 installation and cookie domaine .sondages.pro : this break all system.

Can you test adding this in your .htaccess:
php_value session.cookie_domain "cdsp.sciences-po.fr"

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.
The topic has been locked.
  • zobbyzobba
  • zobbyzobba's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 11 months ago - 9 years 11 months ago #107335 by zobbyzobba
Replied by zobbyzobba on topic Error: Bad Request, CSRF Token
Hi Denis,

Thanks for the answer!

Unfortunately, this don't solve the problem :unsure:
in /limesurvey/path/.htaccess

This is the right .htaccess?

Moreover, the domain cookie not change in phpinfo() with this setting.
Should I remove what I've put in config.php if I put this in .htaccess?

Best Regards,
Last edit: 9 years 11 months ago by zobbyzobba.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 11 months ago - 9 years 11 months ago #107342 by DenisChenu
Replied by DenisChenu on topic Error: Bad Request, CSRF Token
Hi,

Not sure , testing some system, and you don't have same system than me ....
Can not find a real fix here ....

PS: did you have suhosin on this server ? If yes : deactivate it. (simulation on)

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.
Last edit: 9 years 11 months ago by DenisChenu.
The topic has been locked.
More
9 years 8 months ago #110830 by Renier
Replied by Renier on topic Error: Bad Request, CSRF Token
Hi Dennis

I am experiencing the same / similar problem "Bad Request - The CSRF token could not be verified"
The problem is that my client is experiencing this intermittently when submitting pages. (which generally has less than 10 answers on)
We also don't get the problem on the same page.

From 1200 people, 350 completed successfully and only 35 complained about the error.
The problem however is that it is still a significant amount of people.

Please can you give me a idea what I could look for, or how I could go about troubleshooting this problem?

The survey uses TOKENS
Allow multiple responses or update responses with one token = NO
Enable token-based response persistence = YES
We are using Version 2.05+ Build 140618

Regards
Renier
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 8 months ago #110919 by DenisChenu
Replied by DenisChenu on topic Error: Bad Request, CSRF Token
Hi,

Surely some session issue ?

1st idea: uncomment the database session example in your config.php
2nd idea : Disable CRSF validation : manual.limesurvey.org/Optional_settings#Request_settings

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.
The topic has been locked.
More
7 years 11 months ago #133352 by id_wahyu
Replied by id_wahyu on topic Error: Bad Request, CSRF Token
Hi Denis.
I got the "Bad Request CSRF token.." as well. And tried follow the link you provided, try to find it at config.php but failed, I can't find that CSRF part at the config.php
I may open the wrong config.php. Please let me know in which folder that config.php that contain CSRF?

Many thanks

Iwan Wahyu
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 11 months ago #133359 by DenisChenu
Replied by DenisChenu on topic Error: Bad Request, CSRF Token
You must ADD this part to your config.php.

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.
The following user(s) said Thank You: id_wahyu
The topic has been locked.
More
7 years 3 months ago #145735 by JamLizzy101
Replied by JamLizzy101 on topic Error: Bad Request, CSRF Token
Hi Denis

I was looking at this post with your response as I am going through I think the same issue here. We have LimeSurvey set up on the following domain like so: media5.co.za/limesurvey
I created on DNS server a forwarding sub-domain shortsurveys.talkinsight.com with masking so the url - http://media5/limesurvey would then show as shortsurveys.talkinsight.com
I deduced that the issue revolving around getting the message below was the fact that the framework is getting muddled up by the domain name as it knows it is media5.co.za as what is provided by the server and not shortsurveys.talkinsights.com:-
Bad Request
The CSRF token could not be verified

I saw your response to this post. I made a text addition to my config file, bt before adding this, would the below text be ok for what I had described for this to work? :-

'components' => array(

'session' => array(
'savePath' => '/limesurvey',
'cookieMode' => 'allow',
'cookieParams' => array(
'path' => '/',
'domain' => '.talkinsights.com',
'httpOnly' => true,
),
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 months ago - 7 years 3 months ago #145737 by holch
Replied by holch on topic Error: Bad Request, CSRF Token
Offtopic: You might want to revise the text on media5.co.za:

YOU'RE ONE STOP DIGITAL AGENCY.


So what you are currently saying is that visitors to your website are "one stop digital agency"?

I assume what you actually want to say is "Your one stop digital agency" I guess?

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Last edit: 7 years 3 months ago by holch.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 months ago #145747 by DenisChenu
Replied by DenisChenu on topic Error: Bad Request, CSRF Token
'savePath' => '/limesurvey', : remove this : let the the default if it's OK.

I test more with
'path' => '/',
'domain' => 'shortsurveys.talkinsights.com',

but in fact : i'm unsure : depend a lot of server. This can be a broken sessionPath (but you surely don't have the right on /limesurvey directory on server.

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.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose