Home Page - www.tele-pro.co.uk - Ecommerce Integration


Scripts > XSess Secure ASP Session Transfer

ASP Session Transfer Across Domains

Secure ASP Session Transfer
Rate this script at Hotscripts.com

You may have come across a situation where you have two ASP websites, possibly on different servers, and you wish to pass a visitor from site 1 to site 2 whilst retaining all the session variables.

XSess passes the entire session from one ASP webserver to another securely.

XSess consists of a function, and a few supporting functions, contained in an include file.

Include the script xsess.asp in any script from which you intend to transfer the visitor. Also place this script on the destination site. To transfer the visitor whilst retaining the session variables, call the function as follows:

Call XSess("http://www.site2.com/asp/xsess.asp", "/page.asp")

Where "http://www.site2.com/asp/xsess.asp" is the path to this script on the destination webserver, and "http://www.site2.com/page.asp" is the path to actual target URL on the destination.
Technical Information

1. The XSess function will encrypt all the session variables and redirect to the remote script with this encrypted data in the querystring.

2. The remote script will decrypt the variables, set the session and redirect again to the target URL.

NB: Session arrays or objects are not supported

Download Source Code

To download the source code, right-click the following link and select 'Save Target as...''

Download source code and rename the file as xsess.asp.
 

Main Functions

This is the code for the XSess function which transfers the visitor to the destination website:

FUNCTION XSess(xsesspath, destpath)
  'pass this session to xsesspath
  Dim q
  q = "xsessdestpath=" & hsh(destpath) & "&"
  For Each s In Session.Contents
    If Not IsArray(Session(s)) Then
     q = q & hsh(s) & "=" & hsh(Session(s)) & "&"
    End If
  Next
  'redirect to xsesspath
  Response.Redirect (xsesspath & "?" & q)
END FUNCTION

This is the code for the XSess2 function, which receives the visitor on the destination website:

'has data been sent?
'if so update session and redirect
If Trim(request("xsessdestpath"))<>"" Then XSess2()

FUNCTION XSess2()
  Dim dest, a
  'decrypt the query and set the session
  for each a in Request.Querystring
  If (a<>"xsessdestpath") Then
    Session(dhsh(a)) = dhsh(Request.Querystring(a))
  Else
    dest = dhsh(Request.Querystring(a))
  End IF
  next
  'redirect to destination
  Response.Redirect dest
END FUNCTION

Supporting Functions

These generic functions support the XSess functions:

FUNCTION hsh(h)
  hsh = Server.Urlencode(EncryptIt(h, key1))
END FUNCTION

FUNCTION dhsh(h)
  dhsh = DecryptIt(h, key1)
END FUNCTION

Function EncryptIt(it, key)
  Dim keylen, size, encryptstr, keymod, i
  keylen = Len(key)
  size = Len(it)
  encryptstr = ""
  On Error Resume Next
  For i = 1 To size Step 1
    keymod = (i Mod keylen) + 1
    encryptstr = encryptstr & Chr(Asc(Mid(it, i, 1)) + Asc(Mid(key, keymod, 1)))
  Next
  EncryptIt = encryptstr
End Function

Function DecryptIt(it, key)
  Dim keylen, size, decryptstr, keymod, i
  keylen = Len(key)
  size = Len(it)
  decryptstr = ""
  On Error Resume Next
  For i = 1 To size step 1
    keymod = (i MOD keylen) + 1
    decryptstr = decryptstr & Chr(Asc(Mid(it, i, 1)) - Asc(Mid(key, keymod, 1)))
  Next
  DecryptIt = decryptstr
End Function

If you are using ASP Session Transfer please consider making a donation. Why donate?
 

See Also

 Go Free Scripts
 Go Commercial Scripts
 Go Other Developer Websites
 Go Scripts Made to Order
 Go Request Programming Quote
 Go Contact Form Generator
 

Keywords

script, program, free scripts, programming, code, application, utility, javascript, active server pages, asp, asp.net, sql, flash, xml, vbscript, sql, cgi, perl, php, php3, delphi, dhtml, web development, database, resources, unix, wsh, outlook, office automation, ecommerce, remotely hosted, website design
 

Your Feedback is Important

Why not let us know your feedback, or any suggestions you have? Your opinion and feedback is very important to us and to future website visitors, as it enables the continual improvement of products, services, scripts and software available from this website.

Anonymous

Top | Home | ECommerce | Hosting | Site Map | Search | © 2003-6 | Contact