How to remove the session ID from the URL in Magento 2 (frontend). This is the SID query parameter in the URL.

For example: https://example.com/contact/?SID=sfl317buq8ru4uf4a...

Removed starting from 2.3.3 https://github.com/magento/magento2/issues/25663


5 Answers 5


Go to the Store > Configuration > General > Web > Session Validation Settings > Use SID on Storefront and set its value to No


Here is the good answer about the SID:

The SID is a "session ID". Magento uses this to track a user's activity within the same Magento installation. Normally, Magento powers one website and one store from one installation (database).

Magento could power multiple websites with multiple stores from one installation though. The SID allows users to stay logged in while navigating across these websites/stores.

I think if you have the function enabled, the SID is sent when accessing catalog URLs so Magento can update the session with the user's location/state for the current website/store.

If you're not running a multi-website or multi-store environment, it's safe to disable the SID on the frontend.

  • Thanks for reply !!! I go do this and reply the result in a few minutes !!!
    – Matt Silva
    Nov 24, 2016 at 16:33
  • 2
    I've used this approach and disabled SID on the front-end, also Single-store mode set to "Yes", the SID still shows up. In production mode, should we regeneration files to make this work? I don't think so since it's a config value. Any ideas?
    – dchayka
    Jan 13, 2017 at 20:48
  • @dchayka I think this might be a cache issue. Try to refresh it. Jan 16, 2017 at 6:13
  • @SiarheyUchukhlebau cache has been refreshed. I figured out what it is. Thank you for following up.
    – dchayka
    Jan 16, 2017 at 14:12
  • @SiarheyUchukhlebau How Can I change the meta tag for example.com/?SID=nufp7tmaardcoff2ddbp4vmmo6 in magento 2?? Jan 27, 2017 at 6:59

Those of you who already set Use SID on Storefront to No (as Siarhey Uchukhlebau pointed out in his answer) but still can't get rid of &sid=... in the URL, check out following links.

It is a Magento Bug, which will be fixed in version 2.3
Related ticket: https://github.com/magento/magento2/issues/9453

Fortunately, there is a Inchoo Tutorial on how to remove it via .htaccess file as workaround

  • Magento 2.3 is released. Has this been fixed? Can't find anything about it.
    – Akif
    Dec 24, 2018 at 13:24
  • I'm not using Magento 2.3, but in Magento 2.2.6 I'm not facing this issue anymore.
    – michi-p
    Jan 24, 2019 at 10:29

Isn't ?SID automatically added by PHP if PHP is configured to not store sessions on the server or the browser doesn't accept cookies?

I believe Magento doesn't do this by default. There is a setting for it, but I'm assuming that the OP didn't change this, otherwise he would have figured this out by himself.

  • 1
    If the PHP run-time option session.use_trans_sid is enabled, relative URIs will be changed to contain the session id automatically. This option is not on by default. Magento 2's default setting for "Use SID on Storefront" is "Yes".
    – user2868
    Jan 15, 2018 at 21:48

Use Frontend SID removed from store configuration settings from a Magento update. However the value may still be set to 1 in the core_config_data table.

Update your MySQL database table 'core_config_data' and set the value to '0' for path 'web/session/use_frontend_sid'. Do this for all store values.

UPDATE core_config_data SET value = '0' WHERE path = 'web/session/use_frontend_sid';


Find the function and comment the line as below.

public function getUseSessionInUrl()
   // return $this->_useSessionInUrl;
  • 1
    Don't edt Magento core files. Also after the next Composer command, the contents of vendor/magento/framework/ might get restored/updated
    – 7ochem
    May 14, 2018 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.