0

I'm trying to access the shared Sessions stored in SQL Server from multiple applications in different servers.

I already read this Sharing sessions across applications using the ASP.NET Session State Service but I had no luck.

Here's how I set up the web.config of both applications:

<sessionState 
    mode="SQLServer"
    allowCustomSqlDatabase="true"
    sqlConnectionString="Application Name=MyAppName; Data Source=MyDataSource; Initial Catalog=MyDBName; User Id=MyUser; Password=MyPassword"
    cookieless="false" 
    timeout="250" 
/>

And here is the machine key I set up in both config files:

<machineKey validationKey="key1" decryptionKey="key2" validation="SHA1" decryption="AES" />

Both the applications can read and write the database.

I also tweaked the TempGetAppID stored procedure to overcome the application name limitations. In such way my SessionIDs share the same suffix.

That said, I still have 2 different records in the ASPStateTempSessions table, with different SessionIDs.

Here's an example:

3nn53mh3j0vf3mrravuda11o9c8d4bee
oljchatkqzcje1ae1b3n2pst9c8d4bee

Any ideas would be appreciated!

EDIT 1

I tried with both Chrome and IE on a single tab.

Community
  • 1
  • 1
Flea777
  • 1,012
  • 9
  • 21
  • Is that really your machine key or are you just posting that for security reasons? Note that you can't just stick any value in there: http://blogs.msdn.com/b/amb/archive/2012/07/31/easiest-way-to-generate-machinekey.aspx – NightOwl888 Sep 09 '15 at 18:44
  • I am not sure if you also read this: http://stackoverflow.com/questions/10555000/losing-session-state-with-asp-net-sql-server. (There is more than one possible reason, maybe one of those answers will solve your issue) – helix Sep 09 '15 at 18:57
  • @NightOwl888 That isn't my machine key, it's only for example purpose. – Flea777 Sep 10 '15 at 07:03
  • @helix I already read that article but I couldn't find a solution in there. – Flea777 Sep 10 '15 at 07:04

1 Answers1

0

I found the issue.

The problem was that I was (stupidly) trying to share the session between two applications with different host names. In such way, the SessionID was correctly stored in SQL Server but, while one of the applications was able to generate and store the SessionID in the cookie, the other application could not read such cookie because of the different domain.

Flea777
  • 1,012
  • 9
  • 21