Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Check the logged or not using javascript View modes: 
User avatar
Member
Member
nabraham-tibus - 7/21/2011 11:44:49 AM
   
Check the logged or not using javascript
Hi

Is there any way to check the user is logged or not using javascript?

Thanks, Nibu

User avatar
Kentico Support
Kentico Support
kentico_radekm - 7/21/2011 5:04:21 PM
   
RE:Check the logged or not using javascript
Hello.

Yes, it is. Could use e.g. Membership > On-line users web part for this purpose, or use CMS.CMSHelper.SessionManager.IsUserOnline() method.

Best Regards,
Radek Macalik

User avatar
Member
Member
nabraham-tibus - 7/22/2011 2:56:13 AM
   
RE:Check the logged or not using javascript
Hi Radek

Thnaks for the reply. How can i use the code inside the javascript. I want to ckeck the user in logged or not using a javascript fuction.

Can u give the sample code for this issue?

Thanks, Nibu

User avatar
Member
Member
kentico_edwardh - 7/22/2011 5:59:59 PM
   
RE:Check the logged or not using javascript
Hello,

You could use a a web service (or custom aspx page with few query parameters), directly with JS. Or, you could also use a custom web part (with Display to roles set to __authenticated__) that generates simple input:
<input type="hidden" id="isAuthenticated" />

then, you can check whether the user is authenticated using js:

var x = document.getElementById("isAuthenticated");
if (x != null)
{
// user is authenticated
}

Best Regards,
Edward Hillard

User avatar
Member
Member
nabraham-tibus - 7/25/2011 5:15:44 AM
   
RE:Check the logged or not using javascript
Hi Edward

Thanks for the solutions. it works fine.

Nibu

User avatar
Member
Member
nabraham-tibus - 7/25/2011 6:46:26 AM
   
RE:Check the logged or not using javascript
Hi Edward

where we insert the <input type="hidden" id="isAuthenticated" />, any of the web part or header file?

Thanks, Nibu

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 8/3/2011 1:48:51 AM
   
RE:Check the logged or not using javascript
Hello,

It doesn't matter where you insert it. It only has to be accessible from your JS code. If you for example need to display it on all pages, you can insert it into a custom web part in the master page.

Best regards,
Boris Pocatko