Session ID Cookie

Last post 02-12-2007 6:51 AM by Hoonius. 5 replies.

Sort Posts:

  • Session ID Cookie

    02-09-2007, 1:21 PM
    • Participant
      831 point Participant
    • Hoonius
    • Member since 07-13-2006, 8:21 AM
    • England
    • Posts 195

    Hi All

    Since installing the latest AJAX release from Microsoft, has anyone noticed anything different with regards to cookies, namely the Session ID one?

    I had a solution which used the cookie collection to store the scroll positions of a div over AJAX callbacks but this now breaks the Session when i updated the project to use the AJAX 1.0 release version.  It still works for the scroll problem but the SessionID is no longer preserved over a callback and anything stored there is lost.  If i remove the code it all works fine but the scroll position is lost. It used to work fine using the RTM Version of AJAX and i was able to build things and store them in the session and retrieve them no worries.

    The code i'm using is in the AJAX UI section Here. It does seem to clear the cookie collection when it starts collecting the scroll positions but this used to work fine and, to be honest, I never fully understood how repeated calls of

    document.cookie = 

    would add stuff to cookies as it seems to set the value every time rather than concatenate so i'm slightly confused there also.

    Hope you can help and thanks in advance. 

    Any ideas please?

    Tim
     

  • Re: Session ID Cookie

    02-12-2007, 4:09 AM
    • Participant
      831 point Participant
    • Hoonius
    • Member since 07-13-2006, 8:21 AM
    • England
    • Posts 195
    So, any ideas anyone?  Please post even if you haven't noticed any changes, could confirm it either way for me :¬)
  • Re: Session ID Cookie

    02-12-2007, 5:06 AM
    • Contributor
      4,482 point Contributor
    • jodywbcb
    • Member since 03-12-2003, 3:52 PM
    • West Seattle,WA
    • Posts 985

    Do you have the ajax json authentification set up in the web.config?

     

    <

    section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />

    <

    section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />

    <

    section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />

    </

    sectionGroup>

     

    <

    httpHandlers>

    <

    add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

     Not sure if that would be the issue - but may be worth the check if you do not....

    -- jody
    My Blogs on .Net 2.0 and Ajax
    http://csk.wbcb.com
    http://ArtbyJody.com
  • Re: Session ID Cookie

    02-12-2007, 5:18 AM
    • Participant
      831 point Participant
    • Hoonius
    • Member since 07-13-2006, 8:21 AM
    • England
    • Posts 195

    aye, i have that enabled. 


    Here is my configSection node :

     

    1    <configSections>
    2    	<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
    3    		<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
    4    			<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
    5    			<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
    6    				<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
    7    				<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
    8    				<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
    9    			</sectionGroup>
    10   		</sectionGroup>
    11   	</sectionGroup>
    12   </configSections>
    
      

     and i have the httpHandlers bit as well

     

    1    <httpHandlers>
    2    	<remove verb="*" path="*.asmx"/>
    3    	<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    4    	<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    5    	<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
    6    </httpHandlers>
    
      

     

     

  • Re: Session ID Cookie

    02-12-2007, 5:28 AM
    Answer
    • Contributor
      4,482 point Contributor
    • jodywbcb
    • Member since 03-12-2003, 3:52 PM
    • West Seattle,WA
    • Posts 985
    There was a thread on session timeouts and such - before - with Ajax and the roles config in the web.config where (i forget the setting) but it is cookie cache=true; which prevented the role cookie from ever getting updated on asynpostbacks..perhaps this will be related to your issue?  this is one such post http://forums.asp.net/thread/1476142.aspx
    -- jody
    My Blogs on .Net 2.0 and Ajax
    http://csk.wbcb.com
    http://ArtbyJody.com
  • Re: Session ID Cookie

    02-12-2007, 6:51 AM
    • Participant
      831 point Participant
    • Hoonius
    • Member since 07-13-2006, 8:21 AM
    • England
    • Posts 195

    indirectly, that has solved my problem, and i feel terrible having blamed ajax for my own short-sightedness.  God Bless Forums.

    For what it's worth, here are my findings

    Following on for the link you gave me, i started to google cookies and caching and stumbled across the MSDN page about assigning cookies via Javascript.  I found that calls to document.cookie alwasy add to the collection on a key=value basis, so that was 1 point of confusion cleared up :¬)

    However, and here's where my code fits in, i'd had a request to change the javascript.  I used to have it save the scroll position only if scrollTop was greater than zero, which is no use for divs you had scrolled to the top yourself as the new position would not be saved.  So, i removed the check and it bagan saving the scroll position of all divs with an ID, totalling a massive 133 divs on my page.  This is where the problem lies because, according to the MSDN article, only 20 key-value pairs can be stored in the cookie collection.

    There was a similar post where a developer was trying to collect the value of cookie[0].  This is where asp.net stores the sessionID.  I'm presuming that the 21st call to <i>document.cookie = </i> was wiping out the sessionID.  Adding the code to check "scrollTop > 0" has fixed the issue

    Moving on, i think i'll create a new class of Panel which, when scrolled, saves it's scroll position to the cookie and this should overcome the problem of a div that the user scrolls to zero

    Thanks for your pointers Jody, very helpful and I appreciate you taking the time to answer me

    cheers

    Tim

     

Page 1 of 1 (6 items)