Cookies disclaimer

I agree Our site saves small pieces of text information (cookies) on your device in order to deliver better content and for statistical purposes. You can disable the usage of cookies by changing the settings of your browser. By browsing our website without changing the browser settings you grant us permission to store that information on your device.

Session ID Duplication

Session ID Duplication

Contents:

Duplicate Content & Canonicalisation – Session ID Duplication

Session IDs are appended to URLs in order to deal with / handle user sessions. The problem of duplication arises when these session IDs are either used in internal links such as sitemaps, or when they are shared socially.

Although we can take steps to prevent the first issue, we cannot prevent the second issue from occurring. As such your site needs to be protected against this kind of problem (if it uses session IDs).

This article is one of several that fall under the duplicate content and canonicalisation series in the Raptor Knowledge Base. Please the below list for all other articles covering all of the different types of duplicate content and canonicalisation issues that a website can experience below:

Session ID’s

Many sites use session id’s (Session Identifier) appended to URL’s to track user sessions. There are a number of problems that can arise from this that we discuss later in this article. Session ID’s appear in URL’s as alpha-numeric strings attached to a URL which is unique to the ‘session’ of a specific user.

This may look something like this in the URL:

www.example.com.au/page.html&?=views&?session=12345678910111213

A ‘session’ can be defined as the server-side storage of data that you want to keep throughout the user's interaction with the website.

In order to facilitate this, Instead of keeping huge amounts of continually changing data via cookies in the user's browser, only a ‘unique identifier’ is stored on the client side (which is called a "session ID").

The session ID is passed to the web server from the browser every time the browser makes an HTTP request (such as an AJAX request or a page link). The web browser pairs this session id within its own database and recalls the stored data variables for use by the requested page.

Impact of Issue

When a webpage is accessible from multiple URL’s as is the case with session ID’s this can cause a range of problems with Google indexing a site. Specifically the biggest problem is that Google may index each page with its appended session ID as a new page but with identical content, thus a duplicate content issue may arise.

For example, the following URL’s would serve the exact same content but from different URL’s:

www.example.com.au/page.html&?=views&?session=12345678910111213
www.example.com.au/page.html

This could mean that Google starts to serve the top URL in the SERPs.

Another problem is that if a user copies and shares it with a friend, unless server side functionality has been configured to address this issue, it could be that the friend then accesses the site under that session ID.

How to Resolve

Raptor Tools!

Use Raptor’s SEO tools to analyse your site to determine if there are any session ID duplication issues. Our SEO auditing and web crawler software can easily and quickly identify session ID duplication issues.

Using Cookies

In most situations it is better to use session ID’s from within cookies to resolve both of the impacts described above.
A cookie is basically a piece of text stored on a user's computer by a web browser in the form of a text file. Typical uses for cookies are as follows:

  • Authentication
  • Storing website preferences
  • Shopping cart items
  • Server session identification

If we use the [cookie_set] technique it is possible to set cookies to store data for use later on. The code below illustrates how to store a user's session data such as their name and email address. Using this method we would later be able to pre-populate forms with this stored data.

Cookie_Set(
    'UserDetails'='Joe Bloggs|joe.bloggs@example.com.au',
    -Domain='example.com.au',
    -Expires='1440',
    -Path='/'
)

In the example above, the cookie named "UserDetails" contains the user name and email address which has been delimited / separated by a "pipe" character. This can then be read and interpreted; then output in the following code.

local( userDetails = decode_url(cookie('UserDetails'))->split('|'))
if(#userDetails->size)=>{^
    'User Name = '+#userDetails->get(1)
    '<br />'
    'Email Address = '+#userDetails->get(2)
^}

Using Sessions

To store data that is not appropriate to store client-side, sessions are used. The server will automatically both set and retrieve session ID’s. In order to establish a new session, first we must start the session; once this is done we add to it the variables that we want to keep in it. Those variables are stored within the session database.

// Start the session.
session_start(
               'mySessionName',
               -expires = 1440,
               -usecookie=true
)
// Add variables to the session
if(session_result('mySessionName') != 'load') => {
               session_addVar('mySessionName', 'sv_userId')
               session_addVar('mySessionName', 'sv_userName')
               session_addVar('mySessionName', 'sv_userEmail')
               session_addVar('mySessionName', 'sv_favouriteColour')
}
!var_defined('sv_userId') ?           var('sv_userId' = integer)
!var_defined('sv_userName') ?   var('sv_userName' = string)
!var_defined('sv_userEmail') ?    var('sv_userEmail' = string)
!var_defined('sv_favouriteColour') ?        var('sv_favouriteColour' = 'red')

Lines 2-6: Initialises the session. This code needs to occur on every webpage that you want the session data to be both readable and writable. This is where a session named 'mySessionName' with an idle expiry of 1,440 minutes (one day) and set to track via cookie is started.

Lines 9-14: The "if" conditional statement checks the session_result to see if it shows a new session, and if it does, it adds new variables to the session.

Lines 16-19: Each line of code in this section is making a check to see if a variable has been previously defined, and if it hasn’t, the variable is both defined and declared using a default type and default value.

The variables that are appended to the session can now be used just like any other variable in the page. These variables are both readable and writeable. This means that when the value is changed, it will be stored in the session with the new value.

If the session is initialized on successive pages, it is possible to continue both reading and modifying those variables.
Source: Lassosoft

Canonical Tags

This is a topic mentioned in greater detail in another article specific to canonical tags but for the purpose of this article, adding a canonical tag to every page of the site (following the guide above) will prevent most duplicate content issues on any site.

Benefit of Resolving

Controlling the URL’s from which your site & pages can be accessed prevents the potential impact from duplicate content issues.

Sign Up For Early Access
& Earn a Chance to Win 1 Years Free Subscription!

What You Get...

There's no obligation to become a full member after your trial, but we think that once you've seen what's available, you'll want to join us.

We are in the process of building our software and are ramping up to launch the Technical Auditing component in early 2018, soon to be followed by a suite of other components such as keyword ranking and backlink analysis.

Sign up today for 1 months free access and get a further 10% off of any package price when we launch for the first year as a reward for being an early subscriber.

Also, you will be entered into a lottery, where we will be giving away five 1-year subscriptions for free!

Sign up for early access today!