Magento: ?___SID=U appearing in some urls

29,316

Solution 1

I addition to Brendan's answer, the ___SID=U is used in the cache as a placeholder for the session ID. It is replaced by Mage_Core_Model_Url::sessionUrlVar() which in turn calls Mage_Core_Model_Url::sessionVarCallback(). These methods are called from Mage_Core_Block_Abstract::_afterCacheUrl(), which means that any URL found in block output will contain the correct session ID (if needed).

So to get rid of the parameter in your own code the "right way" use this:

$url = Mage::getUrl('some/magento/route'); // might append ___SID parameter
$url = Mage::getModel('core/url')->sessionUrlVar($url); // process ___SID

If the string still displays in the rendered page that is a bug. Are you using some custom caching module, or generating URL's using a non-standard way?

Solution 2

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.

Solution 3

Just something i come across today and though i make a comment, maybe it will help someone. I found that Magento will format/create an incorrect product url (inc. Session Id) if there were some errors during processing the page. This is not consistent though. It worth having a look at your server logs for PHP errors.

Solution 4

This is a general Magento 2 bug which is already reported to magento.

Temporary fix is

Go to Document Root, Find .htaccess and add

RewriteCond %{HTTP_HOST} ^abc.com
RewriteRule ^(.*) www.abc.com/$1 [L,R=301]

below.

This should solve the issue. For me this work in M2.1

All the best.

Reference : https://github.com/magento/magento2/issues/5517

Share:
29,316
Admin
Author by

Admin

Updated on July 09, 2022

Comments

  • Admin
    Admin almost 2 years

    Can someone please explain why ?___SID=U is appearing in some Magento URLs on my site and not others?

    I think it has something to do with sessions but I am not entirely clear. Also, what makes it more confusing is the fact that it's only appearing in some URLs and not others.

    I don't need to know how to remove it as I am aware of the setting in the admin area. I would really like an explanation of what it is, what its purpose is and why it would show on some pages and not others. id rather understand what's going on fully than blindly follow some advice as to how to remove it.

  • Pooch
    Pooch over 10 years
    Saw the same problem, session ID was showing up in an Ajax call due to a PHP error up the chain.
  • Sumith Harshan
    Sumith Harshan almost 8 years
    hi,Thanks for your valuable info. Do you know how to move the payment part to another web servers to same site ? Really appreciate your help. Thanks
  • kiatng
    kiatng over 4 years
    No, Magento 1.x does not requires php-mbstring. See System Requirements. In your case, it is the 3rd party module ManaProg that requires it.