# Fixing the "Invalid CSRF Token" Error

https://docs.wisecp.com/en/invalid-csrf-token-error

"Invalid CSRF Token" means the server refused a form because the security code sent with it did not match your session. The cause is almost always the connection or the hosting setup, not your data.

## When the Message Appears

You see it right after submitting a form, most often on the admin sign-in page. WISECP 3.x shows the message with a link to this article. WISECP 5.x asks you to refresh the page and try again.

In WISECP 5.x, a page opened over a plain `http://` address shows a different message: signing in requires a secure (HTTPS) connection.

## Why It Happens

Every form carries a one-time security code tied to your browser session. The server rejects the form when that code is missing or no longer matches.

- **The page was opened over http**: WISECP 5.x keeps the session only on secure connections. Over http the code is lost on every attempt, so refreshing does not help.
- **The form was sent before the page finished loading**: The sign-in form is sent by a script. Cloudflare Rocket Loader delays scripts, so a quick Enter after autofill can send the form without it.
- **The page stayed open too long**: The code belongs to your session. Once the session ends, the next submission is rejected until you refresh the page.
- **The server cannot store sessions**: If PHP cannot write its session files, for example on a full disk, every attempt fails. Only the hosting side can fix this.

## Tasks

### Fix the Error

1. Open the page with its `https://` address and refresh it.
2. Wait until the page has fully loaded, then fill in the form and send it again.
3. If your site is behind Cloudflare, turn off Rocket Loader under Speed › Optimization, or disable it for the admin folder with a rule. Then purge the Cloudflare cache.
4. If every attempt still fails, ask your hosting provider to check that PHP can write session files.

The form is then accepted and you are signed in.

## Things to Watch

> **A rejected form changes nothing**
> 
> The server stops before it runs the action, so there is nothing to repair afterwards. Send the form again once the cause is fixed.

## Related Articles

- [System Requirements](https://docs.wisecp.com/en/system-requirements)
- [Installing WISECP](https://docs.wisecp.com/en/installing-wisecp)
