how to check from JavaScript if loaded page has ASP.NET authentication cookie?


It looks like JavaScript does not have access to authentication cookies ('ASP.NET_SessionId', '.ASPXFORMSAUTH')

in the http headers I can see cookies but document.cookie object does not have them.


ASP.NET session cookies are <a href="http://en.wikipedia.org/wiki/HTTP_cookie#HttpOnly_cookie" rel="nofollow">HTTP-only</a> by default (and rightfully so). If you need to find out if the user is authenticated in Javascript, putting a HiddenField on the page and setting its value to 0 or 1 based on your authentication token is a much better solution.


You could create a WebMethod which uses the following code to return a true/false value:

[WebMethod] public bool IsAuthenticated() { return HttpRequest.IsAuthenticated; }

Call this from javascript using jQuery or MSAJAX.


  • Should .Net XML Schema Validation stop upon reaching first invalid element?
  • Java JTable: Setting a primary column to always sort by first
  • How can I filter REST calls results based on Roles and current user context in Loopback (server side
  • How to authenticate user name and password against Active Directory Federation Services (ADFS)?
  • Zend framework 2 : Add different authentication adapter for two different modules
  • Spring security - same page to deliver different content based on user role
  • How can I extract results of aggregate queries in slick?
  • Debugging ASP.NET on a built-in web server suddenly stops
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • Spray.io: When (not) to use non-blocking route handling?
  • HTML download movie download link
  • Get object from AWS S3 as a stream
  • Updating server-side rendering client-side
  • Cross-Platform Protobuf Serialization
  • Modifying destination and filename of gulp-svg-sprite
  • Validaiting emails with Net.Mail MailAddress
  • Do I've to free mysql result after storing it?
  • Why winpcap requires both .lib and .dll to run?
  • GridView Sorting works once only
  • AT Commands to Send SMS not working in Windows 8.1
  • bootstrap to use multiple ng-app
  • How to get icons for entities from eclipse?
  • InvalidAuthenticityToken between subdomains when logging in with Rails app
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • Acquiring multiple attributes from .xml file in c#
  • How to set the response of a form post action to a iframe source?
  • How do I configure my settings file to work with unit tests?
  • Setting background image for body element in xhtml (for different monitors and resolutions)
  • Turn off referential integrity in Derby? is it possible?
  • Authorize attributes not working in MVC 4
  • How can I remove ASP.NET Designer.cs files?
  • python draw pie shapes with colour filled
  • Is it possible to post an object from jquery to bottle.py?
  • JaxB to read class hierarchy
  • Is there any way to bind data to data.frame by some index?
  • Busy indicator not showing up in wpf window [duplicate]
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • How can i traverse a binary tree from right to left in java?
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF