Support Overview

Tutorials

Client API Usage Examples

Upgrade Information

FAQ

New Release History

You are here:   Visualware >   MyConnection Server >   Support >   Client API Usage Examples >   Assigning a users browser/OS information as an SID

Assigning a users browser/OS information as an SID

The example below is set to use the users browser type, browser version and operating system as the session ID. This is accomplished using JavaScript.

Code Required

To get started simply copy and paste everything in the box below into the "head" section of the web page. The only change that will be needed is the codebase, highligted in red below. This should be changed to the address of your MyConnection Server installation.

<script>

/* The code below is used to detect the users browser, browser version and operating system. With
each new browser launch it may be necessary to make sure the code is still valid as it's always
subject to change */

var BrowserDetect = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(navigator.userAgent)
|| this.searchVersion(navigator.appVersion)
|| "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
},
searchString: function (data) {
for (var i=0;i<data.length;i++) {
var dataString = data[i].string;
var dataProp = data[i].prop;
this.versionSearchString = data[i].versionSearch || data[i].identity;
if (dataString) {
if (dataString.indexOf(data[i].subString) != -1)
return data[i].identity;
}
else if (dataProp)
return data[i].identity;
}
},
searchVersion: function (dataString) {
var index = dataString.indexOf(this.versionSearchString);
if (index == -1) return;
return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
},
dataBrowser: [
{
string: navigator.userAgent,
subString: "Chrome",
identity: "Chrome"
},
{ string: navigator.userAgent,
subString: "OmniWeb",
versionSearch: "OmniWeb/",
identity: "OmniWeb"
},
{
string: navigator.vendor,
subString: "Apple",
identity: "Safari",
versionSearch: "Version"
},
{
prop: window.opera,
identity: "Opera",
versionSearch: "Version"
},
{
string: navigator.vendor,
subString: "iCab",
identity: "iCab"
},
{
string: navigator.vendor,
subString: "KDE",
identity: "Konqueror"
},
{
string: navigator.userAgent,
subString: "Firefox",
identity: "Firefox"
},
{
string: navigator.vendor,
subString: "Camino",
identity: "Camino"
},
{ // for newer Netscapes (6+)
string: navigator.userAgent,
subString: "Netscape",
identity: "Netscape"
},
{
string: navigator.userAgent,
subString: "MSIE",
identity: "Explorer",
versionSearch: "MSIE"
},
{
string: navigator.userAgent,
subString: "Gecko",
identity: "Mozilla",
versionSearch: "rv"
},
{ // for older Netscapes (4-)
string: navigator.userAgent,
subString: "Mozilla",
identity: "Netscape",
versionSearch: "Mozilla"
}
],
dataOS : [
{
string: navigator.platform,
subString: "Win",
identity: "Windows"
},
{
string: navigator.platform,
subString: "Mac",
identity: "Mac"
},
{
string: navigator.userAgent,
subString: "iPhone",
identity: "iPhone/iPod"
},
{
string: navigator.platform,
subString: "Linux",
identity: "Linux"
}
]

};
BrowserDetect.init();

<!-- END BROWSER/OS DETECTION CODE -->

/* The writeAppletTag code assigns the variable "sid" with the users browser type, version and OS.
It then writes the applet code needed to display the applet. The SID variable is placed in the third line
and prefixed with a * to make the field uneditable */

function writeAppletTag() {

var sid = BrowserDetect.browser+BrowserDetect.version+BrowserDetect.OS;

document.writeln('<applet mayscript name="mcs" code="myspeedserver/applet/myspeed.class" archive="/myspeed/myspeed_s_8.jar,/myspeed/plugins_s_8.jar" codebase="http://mcsiad.visualware.com/myspeed" width=600 height=400>');
document.writeln('<param name="testspecid" value="-2">');
document.writeln('<param name="sid" value="*'+sid+'">');
document.writeln('<param name="permissions" value="all-permissions">');
document.writeln('</APPLET>');

}

</script>

The next stage is to copy and paste the code in the box below where the applet should appear in the web page. All this code is doing is calling the applet code written in the first section.

<!-- The code below simply calls the applet code from above. Place this where the applet should appear-->

<script>writeAppletTag()</script>


 

MyConnection Server

Home
Online Testing Portal
Download
Purchase
Resources
Support

Visualware Products

VisualRoute
eMailTrackerPro
Visual IP Trace

   

© Visualware Inc. 2017 - All Rights Reserved