PHP developer in Nantes

WordPress for businesses in Nantes, delivered remotely by one developer.

PHP developer

My place in the WordPress community

  • I have had a wordpress.org account since 2006.
  • I contributed to WordPress core for versions 7.0 and 7.1.
  • I maintain 30 plugins on wordpress.org.
  • I organise and speak at WordCamps.
  • I have attended every WordCamp Europe from 2017 to 2026.
  • Local WordPress meetup: Nantes WordPress Meetup

My WordPress.org profile

Carved keystone inside Nantes cathedral

Photo: Eusebius, CC BY 3.0, Wikimedia Commons.

A custom PHP application in Nantes gets its security posture from many places. One of them is a French public document: the ANSSI guide on website security standards. This page is by Mariusz Szatkowski, who builds PHP applications from Gdynia, remotely and by email. It reads the guide as a checklist for PHP code and settings, and says where the guide stops.

#Which ANSSI guide applies to a PHP site?

The guide is ANSSI-PA-009, published on the ANSSI site MesServicesCyber. Its full title is “Recommandations pour la mise en oeuvre d’un site web : maitriser les standards de securite cote navigateur”. The version history in the PDF lists version 1.0 of 22 April 2013, version 1.1 of 13 August 2013 and version 2.0 of 28 April 2021, described as a rewrite from the angle of web security standards.

Older material on the web still uses the 2013 title “Recommandations pour la securisation des sites web”. The current guide is the 2021 rewrite. The cyber.gouv.fr publication page did not answer automated requests when I checked, so every statement below comes from the PDF on messervices.cyber.gouv.fr.

Two things in the guide’s own notice matter for a client conversation:

  • It is released under the Licence Ouverte v2.0, so it can be quoted with source and date.
  • Its recommendations are not normative, and the system administrator or the security officers must validate them before implementation.

So this is a reference, not a statute. Whether your organisation treats it as binding is an internal decision, or one for your information security officer.

#Which recommendations map to PHP sessions?

The cookie section of the guide is the part that PHP developers meet first. These are the recommendations, in the guide’s numbering:

RecommendationWhat the guide asksWhere it lands in PHP
R26Except for session tokens, keep sensitive information out of cookiesApplication design: store the data server-side
R28Set the cookie path by least privilegeThe path key of the session cookie parameters
R29 and R30Use HttpOnly where script access is not needed, and always on a session cookiesession.cookie_httponly
R31Use Secure when the site is HTTPS onlysession.cookie_secure
R32Set SameSite to Strict when the cookie is not needed on cross-site navigation, otherwise Laxsession.cookie_samesite
R33A session cookie must define SameSite and must not use Nonesession.cookie_samesite

The guide also advises splitting areas of different responsibility onto separate domains (R27), and notes that not setting the Domain attribute is generally good practice, because the browser then limits the cookie to the issuing host.

The php.net manual lists the defaults that matter here. session.cookie_secure is Off by default. For session.cookie_httponly, session.cookie_samesite and session.use_strict_mode the manual states changed defaults from PHP 8.6.0 (On, “Lax” and On), and says that before that version the first and third were Off and the second was empty. A project that runs an older PHP version, or that cannot rely on a version-dependent default, sets all of them explicitly:

session.cookie_secure = 1
session.cookie_httponly = 1
session.cookie_samesite = "Lax"
session.use_strict_mode = 1
session.use_only_cookies = 1

The same can be done in code before session_start(), with the options array that session_set_cookie_params() accepts:

session_set_cookie_params([
    'lifetime' => 0,
    'path'     => '/',
    'secure'   => true,
    'httponly' => true,
    'samesite' => 'Lax',
]);
session_start();

On session.use_strict_mode and session.use_only_cookies the guide says nothing. They come from php.net: strict mode makes PHP refuse session IDs it did not issue, which the manual says protects against session fixation via session adoption, and use_only_cookies keeps session IDs out of URLs. After a login, session_regenerate_id() replaces the ID, and its manual page shows how to keep the old session from being lost during the swap.

#Which recommendations become response headers?

The guide spends most of its length on headers a browser enforces. In PHP they are header() calls, or the same lines in the proxy or web server in front of PHP. The relevant recommendations:

  • R2, HSTS. The guide’s example asks the browser to use HTTPS only, including subdomains, for one year: Strict-Transport-Security: max-age=31536000; includeSubDomains. It warns that HSTS makes plain HTTP access impossible, so permanent HTTPS must be in place first.
  • R6, Content-Type. Send an explicit, appropriate Content-Type, so the browser does not interpret a response in an unexpected way. For a JSON endpoint in PHP that is a header call before the first byte of output.
  • R14 to R16, CSP. Prefer the Content-Security-Policy HTTP header over a meta tag, avoid the keywords data:, ‘unsafe-eval’ and ‘unsafe-inline’, and always define default-src without leaving it at *.
  • R17 and R18, clickjacking. Use the CSP directive frame-ancestors with a minimal allow list, and an X-Frame-Options header as defence in depth.
  • R21, Referrer-Policy. Define a policy through the Referrer-Policy response header. The default must not be kept, and the value unsafe-url must not be used.

A minimal sketch in PHP:

header('Strict-Transport-Security: max-age=31536000; includeSubDomains');
header("Content-Security-Policy: default-src 'self'; frame-ancestors 'none'");
header('X-Frame-Options: DENY');
header('Referrer-Policy: strict-origin');
header('Content-Type: text/html; charset=utf-8');

The values are examples from the guide’s vocabulary, not a drop-in policy. A real CSP depends on every script, style and font the pages load. The guide also recommends studying the sensitivity of pages before switching on CSP violation reports (R19). For the three places where a CSP header can be set, the guide names the reverse proxy configuration, a request to the hosting provider, and the security settings of the CMS or framework in use. A header() call counts as the framework level. If a proxy already sets the same header, one of the two should own it, so the response does not carry conflicting copies.

The practical effect of R15 is on templates. Inline script blocks and inline event handlers stop working under a policy without ‘unsafe-inline’, so PHP views that rely on them need their JavaScript moved to files. That is my reading of the recommendation, and it is where most of the work sits in an older code base.

#How does the CSRF token recommendation work in PHP?

R38 asks for an anti-CSRF token on XHR calls. The token must hold a random value from a cryptographic generator with at least 128 bits of entropy. The guide gives 22 random characters from the 62 characters A to Z, a to z and 0 to 9 as one way to reach that. It lists two ways to hand the token to the client: a dedicated response header, or an HTML meta tag.

The php.net manual describes random_bytes() as returning cryptographically secure random bytes, so 16 bytes meet the 128 bit floor:

$_SESSION['csrf'] ??= bin2hex(random_bytes(16));

The check on the server compares the received value with the session value, and hash_equals() from php.net does that comparison in constant time.

#What does the guide not cover?

Version 2.0 is about browser-side standards. It does not discuss PHP error messages or the PHP version banner, so there is no ANSSI recommendation to cite for them. Both are covered by php.net:

  • Error display. The manual describes display_errors as a feature to support development that should never be used on production systems, and the bundled php.ini-production sets it to Off. It advises error logging in place of error displaying on production sites, which is the log_errors directive.
  • Version banner. expose_php adds the PHP version to the X-Powered-By header. It can only be set in php.ini.
display_errors = Off
log_errors = 1
expose_php = Off

Hiding the banner is housekeeping, not protection, and the guide does not claim otherwise.

#Checklist for a Nantes PHP application

  • Session cookie: Secure, HttpOnly, SameSite Lax or Strict, narrow path, no Domain attribute unless needed.
  • Set session.use_strict_mode and call session_regenerate_id() after login.
  • HSTS only after HTTPS is permanent on every host the header covers.
  • CSP via header with default-src defined and no ‘unsafe-inline’; frame-ancestors and X-Frame-Options.
  • Referrer-Policy set to a value the guide allows.
  • Random CSRF token of at least 128 bits from random_bytes().
  • display_errors off and log_errors on in production.
  • Remember that the guide is not normative: record who validated the choices.

#How a project runs

  1. You send the application address, the framework, the PHP version and the hosting setup. I answer by email the same or the next working day.
  2. I write down the scope and my assumptions, including which headers the proxy already sets.
  3. I change a staging copy, and you test the login, the forms and the embedded content.
  4. The change goes live only after you sign off in writing.

Everything is remote. The wider PHP offer sits on the PHP developer page. If the site runs on WordPress, there is a maintenance plan for updates. If you want the guide checked against your application, send the scope through the contact page. You get the first written estimate without charge.

Need this service: PHP developer in Nantes?

Describe your project by e-mail. I reply within 24 hours.

Describe your project

Latest PHP developer articles

Dec 2, 2026

Laravel Rust: what does it mean for PHP apps?

On 1 December 2026 Taylor Otwell shipped the Laravel Rust beta, and Laravel Go followed a day later. What the framework contains, what the 18x benchmark really measures, what happens to Laravel PHP and WordPress, and when a rewrite makes sense.

Explore other WordPress services and knowledge base