Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Check if the current user is logged in?Check if the current user is logged in?
Previous
 
Next
New Post
12/3/2008 7:56 AM
 

Hi all,

I have a module that needs to know if the current user is logged in or not.  Is there an easy way to do this?

Simon

 
New Post
12/3/2008 9:24 AM
 

Depends on what you are really asking.  Do you mean from an administrative perspective you only want the module visible to users that are logged in?  If that is the case, restrict the "View" rights to only be visible to "Registered Users". 

If this is not what you are asking, then let me pose a different question.  Do you mean the module itself needs to be aware if the user is logged in or not?  If that is the case, do you control the code for the module itself?  If you don't, then not much you can do besides ask the developer to add the check himself.  If you do control the code, then simply check for "this.UserId > 0".  Assuming true, then the user is logged in.  Assuming false, then the user is not logged in.


-- Jon Seeley
DotNetNuke Modules
Custom DotNetNuke and .NET Development
http://www.seeleyware.com
 
New Post
12/3/2008 12:35 PM
 

Fooberichu wrote
 

... this.UserId > 0 ...

The above is excellent guidance.  One cavil:

My recollection is that DNN uses -1 as the unauthenticated user; code would therefore need to check for UserId >= 0 to be fully robust.

Brandon


Brandon Haynes
BrandonHaynes.org
 
New Post
12/3/2008 1:20 PM
 

Doh!  You're right although I don't think it would ever be possible for UserId to be 0 since default accounts even start numbering at 1 (host) and 2 (admin). 


-- Jon Seeley
DotNetNuke Modules
Custom DotNetNuke and .NET Development
http://www.seeleyware.com
 
New Post
12/4/2008 4:05 AM
 

That's exactly what i was looking for, thanks.

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Check if the current user is logged in?Check if the current user is logged in?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out