Wikipedia

Search results

Avoid Unintended Unnecessary Member Re-logins by Always Coding Templates Using Relative Links

In addition to being a GPT site admin, and a script coder, I'm also a site member at most all of the popular ShiftCode GPTs out there.  Occasionally I've run across a few GPTs where I've noticed an annoying problem based in the way the site admin or designer has coded links.

The symptom of this issue is where I've already logged into the site once for the session and then I click on a link on the site and it prompts me to re-login to the site.

ShiftCode sites usually have at least three ways of accessing the site.  One would be the standard (usually thought of) primary domain name (http://www.mygpt.com), the second would be the domain name without the www. (http://mygpt.com), and the third would be the ShiftCode subdomain (mygpt.shiftcode.com)  That's all fine and good but can cause problems if your links are not all standardized on your template and script coding throughout your entire site.

The re-login issue I speak of is based in the way browser cookies handle all these instances.  With cookies, www.mygpt.com  and mygpt.shiftcode.com are essentially entirely different domains thereby requiring a new cookie for each.  If a member has logged in at www.mygpt.com and then clicks on a link on your site that has been coded to go to a page at mygpt.shiftcode.com then the member will be prompted to re-login in order to see the target page.

This problem may be present on your site right now without you knowing it (and members are not likely to report this particular problem -usually  Though it does tend to reflect negatively on their overall site experience)

To check whether your site has this issue I would suggest taking the time to check each link on your site.  Simply log on to your site as a member and hover over each of the links on your site.  Your browser will show you each link's target somewhere depending upon what browser you are using.  In FireFox it will show where the link goes to in the lower left corner.  ALL of your links should be pointing to your own domain name.  If your see any links pointing to your version of mysite.shiftcode.com then those links are problem links and should be edited.

The best solution to this problem is to get in the habit of always using relative links (/members/promo.php) in code rather that what are called hard coded "fully qualified" links (http://www.mygpt.com/members/promo.php)

A good example in code would be:
<a href="/members/promo.php">Promo Codes</a>

Rather than hard coded links (bad) like:
<a href="http://www.mygpt.com/members/promo.php">Promo Codes</a>
or
<a href="http://mygpt.com/members/promo.php">Promo Codes</a>
or
<a href="mygpt.shiftcode.com/members/promo.php">Promo Codes</a>

The first (good) example will always use the same login cookie no matter how the member enters the site (as long as all your links are relative rather than fully qualified and/or hard coded.)  And the member will remain logged in for their entire visit to your site.   Simple!


No comments: