Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

We have a SharePoint 2010 web application with kind of e-commerce functionality (for example, http://sharepoint-shop). User can save items in the basket which works through default Session State (HttpContext.Current.Session).

Anonymous users can do this too. They pick up the items same way, but before order-workflow is starting user must log in. After this browser redirects user to HTTPS zone (https://sharepoint-shop) and all session data disappeared (HttpContext.Current.Session).

Any ideas, How I can share this session data between multiple zones?

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

The answer was quite simple.

I tried to understand how works a mechanism for storing sessions in ASP.NET. In my case, the sessions stores in the SQL Server database SessionStateService_bf7ce9929397425d9b58d03b91699180 (default provision). This database contains two tables ASPStateTempApplications and ASPStateTempSessions. If you look at this tables you can see the main idea why diffirent applications has diffirent sessions. SessionId column consist of two parts: %SESSION_ID% (HttpContext.Current.Session.SessionID) and second part is the app-hash. App hash is unique for each applications, actually it is hash-function of two variables: AppId and MachineName. AppId generated by dbo.TempGetAppID stored procedure, MachineKey is property of each web.config (or machine-level machine.config).

So all you need to fix the stored procedure and web.config. I added to the dbo.TempGetAppID procedure this line at start:

SET @appName = 'singlesession'

Then I provided same validation and decryption keys in the <machineKey/> config section of web.config for both zones - "http" and "https".

So I got single HttpContext.Current.Session for each web-applications.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.