Articles


Magento snippets

This page contains snippets of information that may help you to configure Magento to suit your needs.

Remove SID from Magento URLs


Magento will append a SID (session ID) to URLs if the url does not match what is set in admin. Thus, if you access the site without the WWW when the Magento config stipulates that WWW is used, you will see this SID.

Mod rewrite can be used to redirect all non-www traffic to the www version - however, you may find this does not work for you. If this is the case, you can over-ride the file which appends the SID to the link. This is a safe way of making changes to Magento, whereby future upgrades will not break this change.

To stop Magento from appending the SID to urls, build the following directory structure under your Magento install:

app/code/local/Mage/Core/Model/Session

Copy the following file into the Session directory created in the previous step:

app/code/core/Mage/Core/Model/Session/Abstract.php

Open the Abstract.php file and locate the following code:

public function getSessionIdForHost($urlHost)
{
if ($this->getSkipSessionIdFlag() === true) {
return '';
}


Change this code to:

public function getSessionIdForHost($urlHost)
{
return '';
if ($this->getSkipSessionIdFlag() === true) {
return '';
}

This change returns before any checking between www and non-www version of the URL, thus the SID does not get appended.




Valid XHTML 1.0!

There are 2 users online

1,080,547 total unique visitors
2,090,502 total pageviews
174 visitors in the last 24 hours
25 total visitors today
44 pageviews today
This page has been visited 7,789 times

Most users online at once:
52 on 12/13/2009