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

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0DNN & Session VariablesDNN & Session Variables
Previous
 
Next
New Post
4/9/2007 2:12 PM
 

I am using few session variables in my custom modules in DNN.  I noticed that sometimes my session variables timeout before my DNN times out.  Also, in other situations, when I logout from DNN my session variables are still there.  How can I link the DNN timeout with my session variables timeout? Also, is there a way to clear my session variables when I logout from DNN?

 

 

 
New Post
4/10/2007 3:45 AM
 

Session variables are a function of ASP.NET and not of DNN. 

Session info is related to a Connection Session - that is - for each web browser connection to the server - there is a session.  This bears no relation to whether a user is logged on to DNN or any other web application for that matter

As for how a session can timeout before DNN - not exactly sure what you are seeing here - if DNN appears to timeout then it is because the session has timed out - these two aspects are directly interrelated.

If you are going to use session variables that are USER specific then you need to be careful how you handle them.
I handle all my access to sesson variables thru a custom class that has two exposed methods

setSession( userid, myKey, myValue)
getSession( userid, myKey )

Both the setSession and getSession methods require a userid parameter
The methods use the userid value to control the validity of the info.

Both method read or Set a "WL_UserID" session variable that I only use inside the methods

The get method always checks the "WL_UserID" session variable and only returns a value if the userid matches the session.

This way - you dont really need to clear session variables when the user logs off - or if the timeouts get out of sync - also you can also code for for lost session / change of user info etc inside the custom class.

For example - if you do a set and the userID does not match the WL_UserID then force all your session info to reset to a default

Westa

 
New Post
4/11/2007 9:33 AM
 

Thanks Westa.  Your have a great suggestion and I will try it myself.  I understand if you answer "no", but could you share the custom class that includes setSession & getSession with us please? 

 

 
New Post
4/11/2007 9:57 AM
 

You should be very carefull with using session variables, as that will cause you some (or a lot of) trouble if you'd ever want to scale up your dnn installation.

DNN never uses session variables anywhere, instead cache is used for non user related data. For user related info you might consider using the DNN personalization class. For a sample of that, check out one of Michael Washingtons blogs: http://www.dotnetnuke.com/Community/BlogsDotNetNuke/tabid/825/EntryID/1153/Default.aspx 


Erik van Ballegoij, Former DNN Corp. Employee and DNN Expert

DNN Blog | Twitter: @erikvb | LinkedIn: Erik van Ballegoij on LinkedIn

 
New Post
4/11/2007 8:33 PM
 

I think this is getting better and better and my brain started to draw a good picture of how my code should look like.  I read what Michael wrote in his Blog and that should simplify many issues I have.  But, since his personalization code is module specific, how can I make it portal specific.  For example, My users are employees who belong to organizations and departments - setup by the administrator.  In almost all my modules I need to know what OrgID and what DeptID they belong to.  Currently, and through one single module, as soon as the user login to the site, I populate session variables with OrgID and DeptID values - I understand now that this is a wrong way to do it. 

Why I use the session variables? Well; one, because I'm so lazy; Two,  I always feel that the more code I write the slower the program gets, and knowing that I can use one single line to retreive the session values rather than passing the user ID to a SP and retreiving the values in every single module I have .. I guess you know what I mean. Any way,  my question is how would you do it, specially when, sometimes, this personalized data exists in a table that does not belong to the DNN core tables.  Yet, I would love to see it there - I mean the data such as OrgID and DeptID - available to me in every module and ready for me to use just with a single line or two of code?

Thank you so much for your help.

 

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0DNN & Session VariablesDNN & Session Variables


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