SessionState SQL-mode authentication

Discussion in 'Site Programming, Development and Design' started by cirwin01, Sep 6, 2010.

  1. I've had nothing but trouble getting persistent (between separate browser sessions) authentication to work.

    OK - I followed the instructions on the support site:

    http://support.Winhost.com/KB/a626/how-to-enable-aspnet-sql-server-session-on-your-web.aspx

    I had them create a database and I put this in my web.config file in the <system.web> section:

    <sessionState mode="SQLServer" allowCustomSqlDatabase = "true" sqlConnectionString="data Source=s03.Winhost.com; database=db_XXXXX_sessionstate;user id=DB_xxxxx_sessionstate_user; password=xxxxxx" cookieless="false" timeout="50000" />

    Nothing has been written to this database - authentication still works but not between sessions. I also changed the database name to be invalid and no error. Why is this line being ignored? Following is my entire web.config file:

    <?xml version="1.0"?>

    <!--
    For more information on how to configure your ASP.NET application, please visit
    http://go.microsoft.com/fwlink/?LinkId=169433
    -->

    <configuration>

    <connectionStrings>
    <add name="CRMConnectionString" connectionString="Data Source=s03.Winhost.com;Initial Catalog=DB_xxxx_crm;User ID=DB_xxxxx_crm_user; password=xxxxx"
    providerName="System.Data.SqlClient" />
    <add name="LocalSqlServer" connectionString="Data Source=s03.Winhost.com;Initial Catalog=DB_12385_crm;User ID=DB_xxxx_crm_user; password=xxxxx"
    providerName="System.Data.SqlClient" />
    </connectionStrings>
    <system.web>
    <roleManager enabled="true" />
    <compilation debug="false" targetFramework="4.0" />
    <authentication mode="Forms">

    <forms name=".ASPXFORMSAUTH" loginUrl="Default.aspx" protection="All" path="/" timeout="5000000" />

    </authentication>
    <authorization>
    </authorization>
    <sessionState mode="SQLServer" allowCustomSqlDatabase = "true" sqlConnectionString="data Source=s03.Winhost.com; database=db_xxxx_sessionstate;user id=DB_xxxxx_sessionstate_user; password=xxxxx" cookieless="false" timeout="50000" />

    </system.web>
    <location path="Admin">
    <system.web>
    <authorization>
    <deny users="?" />
    </authorization>
    </system.web>
    </location>
    <location path="Client">
    <system.web>
    <authorization>
    <deny users="?" />
    </authorization>
    </system.web>
    </location>
    </configuration>


    Can anyone help? By the way, I set the session cookie using the code:

    FormsAuthentication.SetAuthCookie(Username.Text, true);

    HELP???!!!
     
    Last edited by a moderator: Oct 14, 2015
  2. Ray

    Ray

    How are you being made aware that the SQL session is not working? If you are getting an error message, we will need you to provide us a full copy of the error message.
     
  3. OK - Ray, now I'm really confused. I am trying to get persistent authentication to work - maybe this has nothing to do with that SQL session thing... I was simply trying to use a "Keep me logged on" feature using FormsAuthentication.SetAuthCookie(Username.Text, true). I did find that this works on Firefox and my Mac, but doesn't work on IE 8 (but does on another machine.) Yahoo or Google don't remember my authentication either, so I finally figured out that I had the setting "delete browsing history on exit" set.

    Sorry to take your time, but can you tell me - This SessionState in SQL does not have anything to do with the authentication cookies, does it?
     
  4. Ray

    Ray

    I think it will be better if you give me a URL and a test account to use. This way I can run through the steps and understand what you are going through.
     

Share This Page