How to display the current and parent category in WordPress
Need to show the category hierarchy in your theme? Learn how to get the current category and its parent using get_the_category() and get_category_parents().

Photo: DaveM93, CC BY-SA 3.0, Wikimedia Commons.
A web application in Milan that lets people log in with SPID has to follow a published technical specification, not a plugin default. This page is by Mariusz Szatkowski, who writes PHP from Gdynia, remotely and by email. It reads the AgID rules from the PHP side and flags the point where PHP sessions and the login flow collide.
The rules are the “SPID - Regole Tecniche” on Docs Italia, the AgID documentation site. They define how an Identity Provider, a Service Provider and an Attribute Authority integrate through SAML. The version on the stable branch is a consolidated one that includes the AgID notices (Avvisi) that amended the rules, up to Avviso n. 34.
A PHP web application that offers the login is the Service Provider. It sends a login request, receives a signed response and decides who the user is. Everything below concerns that role.
A second document on the same site, “SPID/CIE OpenID Connect”, describes SPID and CIE id on the OpenID Connect standards (OpenID Connect Core, the iGov profile and OpenID Connect Federation 1.0). I read its introduction only. Whether a given public service has to use the SAML route or the OpenID Connect route depends on the current AgID rules for that service, and that is a question for the service owner, not something I can settle from here. I am not a lawyer.
The login starts when the user picks an Identity Provider through the official “Entra con SPID” button. The Service Provider then builds an AuthnRequest. The rules list what it must carry:
| Element | Rule in the SPID rules |
|---|---|
| ID | Unique, for example a UUID, or origin plus a timestamp with at least millisecond precision |
| Version | Always 2.0 |
| IssueInstant | UTC, for example 2017-03-05T18:03:10.531Z |
| Destination | The Location of the Identity Provider SingleSignOnService |
| ForceAuthn | Present when a level above SpidL1 is requested |
| AssertionConsumerServiceIndex | Points to an entry in the Service Provider metadata, with the HTTP-POST binding |
| IsPassive | Must not be present |
| Issuer | The entityID from the metadata, with Format entity and a NameQualifier |
| NameIDPolicy | Format transient |
| RequestedAuthnContext | SpidL1, SpidL2 or SpidL3, with Comparison exact, minimum, better or maximum |
With the HTTP-POST binding the request carries an XML signature made with RSA keys of at least 2048 bits and a SHA-256 or stronger digest. With HTTP-Redirect the signature travels in the SigAlg and Signature query parameters, with the same key and digest floor. The RelayState must reveal as little as possible about the requested resource, so an opaque value that maps to the target on the server fits better than a path.
In PHP the two request fields that are easy to get wrong are the ID and the timestamp:
$id = '_' . bin2hex(random_bytes(20));
$issued = (new DateTimeImmutable('now', new DateTimeZone('UTC')))
->format('Y-m-d\TH:i:s.v\Z');The php.net manual describes random_bytes() as returning cryptographically secure random bytes, which is more than the rules ask for the ID, and the date format character v gives milliseconds on a DateTimeImmutable.
The Identity Provider returns a Response by the HTTP-POST binding only. The rules list what the Service Provider must verify before it uses the assertion:
The Service Provider must also make sure assertions are not replayed. It keeps the set of request IDs for as long as the assertion is valid according to NotOnOrAfter, and it accepts only Responses that match an earlier, unexpired request. Unsolicited Responses are discarded. The assertion itself carries an AudienceRestriction with the entityID of the Service Provider, and the AuthnContextClassRef with the level that was actually used.
That last field matters. The rules say an Identity Provider may authenticate at a higher level than the request implies through Comparison, and that this must not make the request fail. An application that demands SpidL2 and tests for equality would reject a valid SpidL3 login. The check is on the level in the assertion, against the minimum the service needs.
$pending = $requests->takeOnce($inResponseTo); // your own store, one use only
if ($pending === null || $pending['expires_at'] <= time()) { reject(); }
if ($recipient !== $acsUrl) { reject(); }
if ($notOnOrAfter <= time()) { reject(); }
if ($audience !== $spEntityId) { reject(); }The signature checks themselves belong in a maintained SAML library rather than in hand-written XML handling. Two php.net facts apply wherever XML is parsed from a browser POST. The manual says external entity loading in libxml is disabled by default as of PHP 8.0, and that libxml_disable_entity_loader() is deprecated for that reason. And openssl_verify(), which verifies a raw signature such as the one in the Redirect binding, uses SHA-1 as its default algorithm, so the call needs OPENSSL_ALGO_SHA256 or stronger passed explicitly to meet the SHA-256 floor.
This is the trap that cannot be found in the SPID rules. It sits between them and PHP.
The Response comes back as a POST that the user’s browser sends from the Identity Provider’s page to the application. That is a cross-site POST. The php.net manual states, for session.cookie_samesite, that the values Lax and Strict mean the cookie is not sent cross-domain for POST requests, and that Lax still sends it for cross-domain GET requests. With a SameSite value on the session cookie, which the manual also lists as the default from PHP 8.6.0, the endpoint that receives the Response does not see the session that started the login.
A login flow that stores the pending request ID only in $_SESSION therefore fails, and it fails only on real browsers behind a real Identity Provider. The fix is to store each pending request on the server, keyed by its ID, with the RelayState, the minimum level and an expiry time. The receiving endpoint finds the request through InResponseTo, uses it once, and starts the authenticated session after the checks pass. That also fits the replay rule above, because the store of used IDs is the same table.
Two session habits follow. The session cookie stays on Lax or Strict, not None, because None would widen the cookie to every cross-site request. And once the assertion is verified, session_regenerate_id() gives the user a fresh ID, so a session ID set before login is not carried into the authenticated state. The php.net manual shows how to do the swap without losing the session.
The rules on metadata and algorithms set the floor for every Service Provider:
One detail to treat with care: the example URL in the Redirect binding section of the rules shows a SigAlg ending in rsa-sha1, while the rule text asks for SHA-256 or stronger. A PHP implementation follows the text. That is my reading of an inconsistency in the document, and the Identity Provider test environment is the place to confirm it.
The rules separate two sessions. An Identity Provider keeps an authentication session only after a SpidL1 login. For SpidL2 and SpidL3 no session is created, and every request repeats the authentication. The Service Provider has its own individual session for the service. Logout messages travel between the two, as a LogoutRequest and a LogoutResponse. The LogoutRequest must carry a unique ID, Version, IssueInstant and Destination, like the login request.
For the application this means that logging out of the PHP session is not the end of the SPID flow. Which logout mechanism a given service has to implement is set by the rules for that service, and the single sign-on and logout pages of the rules are the source.
Everything is remote. See the PHP developer page for the overall offer, and the maintenance plan page for WordPress sites. If you plan a SPID login, send the scope through the contact page. The first estimate in writing is free of charge.
Examples of my work.
EclipseSource, founded in 1997, is a global leader in Eclipse technologies, with a strong presence in Europe and North America, specializing in enterprise so...
estel-poland.com is a professional online store for cosmetics, created for customers seeking high-quality skincare and makeup products. The platform is desig...
gdasj.pl is a local website from Gdansk, built for simple publishing, good performance, and clear access to content.
Describe your project by e-mail. I reply within 24 hours.
Describe your projectNeed to show the category hierarchy in your theme? Learn how to get the current category and its parent using get_the_category() and get_category_parents().
Need to get the URL of the first image or link in an article? Prefer DOMDocument over regex. Ready-made WordPress PHP for developers.
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.
Custom WordPress engineering and architecture.
Scalable headless, ERP, and AI architecture for enterprise.
Stores, checkout flow, and sales logic.
Stability, updates, and post-launch support.
What the monthly care fee covers and what changes it.
Business process automation around WordPress and company systems.
Headless WordPress, Sanity, Strapi, and Contentful with Astro or Next.js.
Astro, MDX, edge delivery, and Core Web Vitals measured on real traffic.

How to start as a WordPress developer in 2026. Local environment, theme and plugin development, REST API and headless paths, security and Core Web Vitals. A practitioner playbook that does not waste your first month.

WordPress 7.0 with AI Client against Astro 7 with the Rust compiler and Vite 8. Speed, cost, SEO and security compared, plus the real bill for my own Astro 6 to 7 migration.

A detailed comparison table of EmDash CMS and WordPress across architecture, security, plugins, AI features, content model, hosting, and ecosystem maturity.