Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Session ID parameters in URLs: how to find and fix duplicates

SEO-059Medium impactOther toolBy FunnelGuardPublished Updated
On this page

What this issue is

A session ID is a random code a website uses to remember a visitor, for example to keep a basket between pages. Normally it is stored in a cookie. Some older setups, or setups where cookies are blocked, add it to the URL instead: https://example.com/shoes?PHPSESSID=8f3a2c or https://example.com/shoes;jsessionid=1A2B3C.

Common session ID patterns
PatternTypical source
?PHPSESSID=...PHP with session.use_trans_sid or session.use_only_cookies off
;jsessionid=...Java servers such as Tomcat (URL rewriting)
?sid=... or ?sessionid=...Custom code, older carts and forums
?ASP.NET_SessionId or (S(...)) in pathASP.NET cookieless sessions

Why it costs you leads or sales

How one page becomes many URLs
  1. Visitor or crawler arrivesNo cookie accepted
  2. Server adds session ID?PHPSESSID=new code
  3. Many URLs, one pageDuplicates crawled
  4. Signals splitWeaker rankings

Each visit gets a new ID, so signals are split.

Crawled URLs for one product pageExample numbers
Crawled URLs for one product page (example)Before fix: 40 URLs; After fix: 1 URLs01531401Before fixAfter fixURLs

Example: illustrative numbers showing how session IDs multiply crawlable URLs for a single page.

How to check if your site has it

Find session ID URLs
  1. Search Google for the pattern

    Try site:yourdomain.com inurl:PHPSESSID, then inurl:jsessionid and inurl:sid=. Any results mean session URLs are indexed.

  2. Check Search Console

    In Pages (Indexing), look at the lists for 'Duplicate without user-selected canonical' and 'Alternate page with proper canonical tag'. Inspect any URL containing a session parameter.

  3. Crawl the site

    Run a crawler such as Screaming Frog and filter the URL list for session, sid or jsessionid. Note which pages link to those URLs.

  4. Test with cookies off

    Open a private window, block cookies in browser settings and click through your site. If the address bar gains an ID, your server falls back to URL sessions.

  5. Check server logs

    Search access logs for Googlebot requests that include the parameter to see how much crawl it takes.

How to fix it

Stop session IDs in URLs
  1. Find the source

    WordPress core does not put session IDs in URLs. Look for a plugin or theme that calls session_start() and enables URL sessions. Deactivate plugins one by one on a staging copy to find it.

  2. Disable URL sessions in PHP

    Use the PHP settings in the next code block via php.ini, .user.ini or your host's PHP settings panel.

php.ini settingstext
session.use_cookies = 1
session.use_only_cookies = 1
session.use_trans_sid = 0
Java web.xmltext
<session-config>
  <tracking-mode>COOKIE</tracking-mode>
</session-config>
Clean up existing session URLs
  1. Remove internal links with IDs

    Fix templates, menus, sitemaps and redirects so no internal link contains the parameter.

  2. Redirect to the clean URL

    Add a 301 redirect from any URL with the session parameter to the same URL without it. See the Apache example below.

  3. Add a self-referencing canonical

    Make every page output <link rel="canonical" href="https://example.com/shoes"> with the clean URL and no parameters. This is a backup for URLs that still slip through.

  4. Keep session URLs out of the sitemap

    Your XML sitemap should list only clean URLs.

Apache: 301 redirect PHPSESSID URLs to the clean URLhtaccess
RewriteEngine On
RewriteCond %{QUERY_STRING} (^|&)PHPSESSID=[^&]*(&|$)
RewriteRule ^(.*)$ /$1? [R=301,L]
URLs before and after

Before

  • /shoes?PHPSESSID=8f3a2c
  • /shoes?PHPSESSID=91bd07
  • No canonical or a canonical with the ID

After

  • /shoes is the only URL
  • Session kept in a cookie
  • Old ID URLs 301 to /shoes

How to confirm it's fixed

Confirmation checks
  • Browse with cookies blocked: no ID appears in the address bar.
  • Open an old session URL: it 301 redirects to the clean URL.
  • View source on a page: the canonical has no session parameter.
  • A fresh crawl finds no internal links with the parameter.
  • Basket, login and checkout still work with cookies on.
  • Search Console URL Inspection on a clean URL shows it as the Google-selected canonical.
  • site:yourdomain.com inurl:PHPSESSID shrinks over the following weeks.

How to prevent it happening again

Prevention
  • Keep sessions cookie-only in server config and put that config in version control.
  • Add a canonical template rule that strips all query parameters you do not need.
  • Test new plugins, carts and server upgrades with cookies blocked.
  • Re-crawl monthly and filter for session parameters.
  • Review Search Console duplicate URL reports after any platform change.

How FunnelGuard handles this

FAQ

Questions people ask

Why are session IDs in my URLs?

Your server falls back to URL-based sessions, usually when a visitor or crawler does not accept cookies, or when it is configured to rewrite URLs. In PHP this is session.use_trans_sid, in Java it is URL rewriting with jsessionid.

Do session IDs in URLs hurt SEO?

Yes, they can. Each visit creates a new URL for the same content, which splits ranking signals, wastes crawl budget and can get duplicate URLs indexed. The effect is usually medium, but it grows on large sites.

How do I remove PHPSESSID from URLs?

Set session.use_only_cookies=1 and session.use_trans_sid=0 in php.ini or your host's PHP settings. Then 301 redirect old PHPSESSID URLs to the clean URL and fix any internal links containing the parameter.

Should I use a canonical tag or a redirect for session ID URLs?

Use both if you can. A 301 redirect sends visitors and crawlers to the clean URL, and a self-referencing canonical on the clean page is a safety net for URLs that still appear.

Can I block session ID URLs in robots.txt?

It is better not to. If Google cannot crawl a URL it cannot see the canonical tag or redirect, and the URL can still be indexed from links. Fix the cause and redirect instead.

How do I find session ID URLs that Google has indexed?

Search site:yourdomain.com inurl:PHPSESSID or inurl:jsessionid, and review the Pages report in Google Search Console for duplicate URLs. A site crawl will also list any with the parameter.

Does FunnelGuard detect session IDs in URLs?

No. FunnelGuard does not check for this yet. It monitors your customer journeys, tracking hits and lead delivery, so use a crawler and Search Console to watch for session URLs.

Does FunnelGuard catch this?

Other tool

Needs a different kind of tool.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.