Magento: ?___SID=U appearing in some urls

后端 未结 5 1339
慢半拍i
慢半拍i 2020-12-09 04:00

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 entir

相关标签:
5条回答
  • 2020-12-09 04:24

    I hunted for hours to find this and the precise answer was a combination of the other answers listed here. First, I cranked up my PHP error reporting and error logging (thanks Gergely Varga). I saw this:

    PHP Fatal error:  Call to undefined function mb_strrpos() in /var/www/html/app/code/local/ManaPro/FilterAjax/Model/Observer.php on line 59
    

    So, one of our installed extensions requires the php-mbstring package, which my server didn't have installed. As soon as I installed that, the SID=U URLs all disappeared. (In future I'll be running Magento's pre-install checks before copying an existing install over to a new server!)

    Thanks to Vinai too for the background of what this tag is for.

    0 讨论(0)
  • 2020-12-09 04:25

    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.

    0 讨论(0)
  • 2020-12-09 04:26

    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

    0 讨论(0)
  • 2020-12-09 04:28

    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?

    0 讨论(0)
  • 2020-12-09 04:32

    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.

    0 讨论(0)
提交回复
热议问题