麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學院 > 開發設計 > 正文

讓Session對象在不同域名下實現共享

2019-11-18 22:15:26
字體:
來源:轉載
供稿:網友
There is a general belief among developers that session state maintenance is always against one
domain / site. And therefore one can not maintain session state across different domains. Usually there is
no such requirement to maintain session state across different domains. But of late due to increase in the
scope of web based applications developers feel the need to share the session state with other domains.
The other domain may be a sister concern of the same company, or may be the B2B partner. So the question
arises how one can share the session variables across other domains easily and safely.

--------------------------------------------------------------------------------


  
How to share Session variables across Domains


Introduction  
      There is a general belief among developers that session state maintenance is always against one
domain / site. And therefore one can not maintain session state across different domains. Usually there is
no such requirement to maintain session state across different domains. But of late due to increase in the
scope of web based applications developers feel the need to share the session state with other domains.
The other domain may be a sister concern of the same company, or may be the B2B partner. So the question
arises how one can share the session variables across other domains easily and safely.

  

Sharing Session variables using aSMS  
     
      Configure aSMS


      Sharing Session variables across domains is very easy using aSMS. aSMS Standard and Advanced both
support sharing session variables. Lets assume two different domains mydomain1.com and mydomain2.com. And
the requirement is to share the session variables between mydomain1.com and mydomain2.com. For simplicity
sake lets assume one webserver each for mydomain1.com and mydomain2.com. (It’s also possible so share
session variables between different domains hosted on same webserver). So www.mydomain1.com points to
webserver of domain1 and www.mydomain2.com points webserver of mydomain2.com.

Install aSMS on both webservers. Both aSMS should share a common LDAP server to share session variables.
Lets assume that common LDAP server be ldap.mydomain.com. On the webserver of mydomain1.com, open the aSMS
Admin Console.

For the,

LDAP Path enterLDAP://ldap.mydomain.com:1002/o=mydomain/ou=Members
LDAPAdminentercn=Administrator,ou=Members,o=mydomain

Enter the Admin PassWord. Set your Session Time out duration. If you want to support cookies then set
Support Cookies to True.




Click ‘Test LDAP Source’ button. If it returns ‘Successful’ Then aSMS has been configured successfully
on the webserver of mydomain1.com.




Do the same on the webserver of mydomain2.com. Take care to enter the same LDAP path
(LDAP://ldap.mydomain.com:1002/o= mydomain/ou=Members)for the webserver of mydomain2.com. This way we
ensure that aSMS of both webservers point to the same LDAP Server. Test LDAP connection by clicking ‘test
LDAP source’ button. If it returns successful then aSMS has been configured PRoperly on webserver of
mydomain2.com also and they both point to the same LDAP server.

  
     
Start Session on Webserver of mydomain1.com


  One can use the functions.asp (link to function.txt) given in the sample files and include this file in
all asp pages. If functions.asp has been used then Session can be started by just calling SessionStart
function on the default.asp of mydomain1.com webserver.

If function.asp is not used, then following code can be used to start the session in default.asp page

< %

Set objSession = Server.CreateObject("Session.Management")

objSession.SessionStart()

Set objSession = nothing

% >

To assign session variables in mydomain1.com

< %

Set objSession = Server.CreateObject("Session.Management")

objSession.CheckSession()

objSession.SetSession "givenname", John

objSession.SetSession "sn", Anderson

objSession.SetSession "mail", [email protected]

objSession.SetSession "userPassword", password

objSession.SetSession "accountStatus ", 1

Set objSession = nothing

% >

To retrieve Session variables

< %

Dim strFirstName, strLastName, strEmailAddress

Dim strPassword, intStatus

Set objSession = Server.CreateObject("Session.Management")

objSession.CheckSession()

strFirstName = objSession.GetSession ("givenname")

strLastName = objSession.GetSession ("sn")

strEmaiAddress = objSession.GetSession ("mail")

strPassword = objSession.GetSession ("userPassword")

intStatus = objSession.GetSession ("accountStatus ")

Set objSession = nothing

% >

  
     
Sharing Session Variables   


      To share the session variables between domains, one need to pass the SessionGUID value to the other
domain. aSMS maintains session by using this SessionGUID. This can be done by passing the ‘SessionGUID’
cookie value to other domain by either query string or by hidden form field.

<ahref=http://www.mydomain2.com/default.asp?SessionGUID= <%= Request.Cookies (“SessionGUID”)% > >
MyDomain2.com< /a>

Add few lines just after SessionStart code in default.asp of mydomain2.com domain.

< %

Set objSession = Server.CreateObject("Session.Management")

If Request.QueryString ("SessionGuid") <> "" Then

Response.Cookies ("SessionGuid") = Request.QueryString ("SessionGuid")

Else

objSession.SessionStart()

End If

Set objSession = nothing

% >

To retrieve mydomain1.com’s session variables

< %

Dim strFirstName, strLastName, strEmailAddress

Dim strPassword, intStatus

Set objSession = Server.CreateObject("Session.Management")

objSession.CheckSession()

strFirstName = objSession.GetSession ("givenname")

strLastName = objSession.GetSession ("sn")

strEmaiAddress = objSession.GetSession ("mail")

strPassword = objSession.GetSession ("userPassword")

intStatus = objSession.GetSession ("accountStatus ")  

objSession = nothing

% >  

This way we can share session variables between two different domains using aSMS.

  
     
Scenarios, where sharing Session Variables Across Domains may be required


Sharing session variables is required in so many types of web scenarios. Some of them are-

1. Common Login between two different domains - If you don’t want the users who have logged in
mydomain1.com to once again be validated in mydomain2.com.

2. Sharing Session variables with your B2B partner.

3. Developing your own ‘Microsoft Passport’ like web site.


  

Conclusion    
  
       Here we have seen how by using aSMS one can easily share session variables across two different
domains. This method has been actually implemented on live web sites. Menswear.com
(http://www.menswear.com) and Womenswear.net (http://www.womenswear.net ) use aSMS to share session state
across two of their domains. When users go from menswear.com to womenswear.com, they need not re-login.
Users need to login only at either menswear.com or at womenwear.com. The authentication details are shared
between two domains.

Download sample code for this page.
http://files.driveway.com/download/vapp03-653b18dcaf1f3ccb/28271119/Sharing+Session+Variables+Samples.zip




發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 免费看a级片| 毛片在线播放视频 | 亚洲精品成人18久久久久 | 九九热免费观看 | 欧美日韩成人一区二区 | www噜噜偷拍在线视频 | 一级视频在线播放 | av免播放| 成人9禁啪啪无遮挡免费 | 久久撸视频 | 干少妇av | 国产精品99精品 | 精品久久中文字幕 | 黄色网战入口 | 免费黄色入口 | 午夜精品福利在线观看 | 美女扒开腿让男生桶爽网站 | 依人在线视频 | 911精品影院在线观看 | 成人三级电影网 | 国产91久久久久久 | 久久久久久久久浪潮精品 | 在线播放免费人成毛片乱码 | 国产羞羞视频在线观看 | 亚洲无马在线观看 | 最新av免费网址 | 国产精品视频一区二区三区四区国 | 国产二区三区四区 | 看国产一级毛片 | 欧美久久久一区二区三区 | 欧美亚洲综合在线 | 爽爽淫人网 | 4p一女两男做爰在线观看 | 久久九九热re6这里有精品 | 国产无限资源在线观看 | 亚洲经典视频 | 一级国产精品一级国产精品片 | 色妞妞视频 | 精精国产xxxx视频在线播放7 | 国产女同疯狂激烈互摸 | 国产精品欧美久久久久一区二区 |