Alpha Video Training
Results 1 to 16 of 16

Thread: Session variable question

  1. #1
    "Certified" Alphaholic
    Real Name
    Jetson Lilibeth
    Join Date
    Dec 2011
    Posts
    1,083

    Default Session variable question

    I received an email from Amy Gorden and the article is about Lee Vasic a featured developer for Q4 on IADN, and in one of his tips (pls see attached file) , he mentioned
    something about avoiding session variable and instead use arguments. I got confused and a bit worried because I used session variables extensively in my app.

    How do I automatically logout the app after 15 minutes? or how to automatically logout the app if I close the browser?

    Thanks!
    Attached Images Attached Images

  2. #2
    "Certified" Alphaholic kkfin's Avatar
    Real Name
    Kenneth
    Join Date
    Dec 2006
    Location
    EU
    Posts
    1,520

    Default Re: Session variable question

    Actually I am not sure what is the actual question here. But I assume it has something to do with the picture attached. If so then LV is maybe referring to the new feature in Alpha so when you define an argument (and then an array argument) in UX you can now bind it to the logged in user id (or group) in security. In Alpha Anywhere Demo some time ago Selwyn was ready to explain more of this topic but unfortunately time run out.

    Or maybe LV means something else.

  3. #3
    "Certified" Alphaholic
    Real Name
    Jetson Lilibeth
    Join Date
    Dec 2011
    Posts
    1,083

    Default Re: Session variable question

    Hi Kenneth, THanks for the reply, Based on the image attached, I encircled the "dont use session variables" what is then the best way or alternative?

  4. #4
    "Certified" Alphaholic kkfin's Avatar
    Real Name
    Kenneth
    Join Date
    Dec 2006
    Location
    EU
    Posts
    1,520

    Default Re: Session variable question

    I do not see any problems with session variables in a web application. Mobile is an other thing.

  5. #5
    "Certified" Alphaholic
    Real Name
    Jetson Lilibeth
    Join Date
    Dec 2011
    Posts
    1,083

    Default Re: Session variable question

    Thanks for the clarification Kenneth.

  6. #6
    "Certified" Alphaholic
    Real Name
    Rich Fulham
    Join Date
    May 2011
    Location
    Portland, OR
    Posts
    1,002

    Default Re: Session variable question

    Sorry, but I disagree with Ken. Session variables are fraught with problems. Maybe he has a web application that works with session variables, but I wonder... Is it me or Ken that is in the minority here. Just search this newsgroup for "Session variable".

    Another thing to do is make sure you have xbasic logging turned on in a test application (or maybe even your production app, if you don't have too many users) and then periodically check the log for "Property not found" where a session variable is involved. Three times today, my production server randomly "forgot" about a particular session variable (or it did not have time to finish saving the variable before it was needed by the next page). I started a new xbasic log on Nov 28. From then until Jan 8, this error has occurred 30 times. Now, it is possible the users really did timeout (or at least their session variables timed out), but since I have seen this error happen to me and because of the page this error happens on, I would say it is a real error.

  7. #7
    "Certified" Alphaholic kkfin's Avatar
    Real Name
    Kenneth
    Join Date
    Dec 2006
    Location
    EU
    Posts
    1,520

    Default Re: Session variable question

    Quote Originally Posted by RichCPT View Post
    Sorry, but I disagree with Ken. Session variables are fraught with problems. Maybe he has a web application that works with session variables, but I wonder... Is it me or Ken that is in the minority here. Just search this newsgroup for "Session variable".

    Another thing to do is make sure you have xbasic logging turned on in a test application (or maybe even your production app, if you don't have too many users) and then periodically check the log for "Property not found" where a session variable is involved. Three times today, my production server randomly "forgot" about a particular session variable (or it did not have time to finish saving the variable before it was needed by the next page). I started a new xbasic log on Nov 28. From then until Jan 8, this error has occurred 30 times. Now, it is possible the users really did timeout (or at least their session variables timed out), but since I have seen this error happen to me and because of the page this error happens on, I would say it is a real error.
    So is your point here that session variables are broken in Alpha platform?

  8. #8
    "Certified" Alphaholic mikeallenbrown's Avatar
    Real Name
    Mike Brown
    Join Date
    Nov 2009
    Location
    United States
    Posts
    1,753

    Default Re: Session variable question

    Rich: Have you cross referenced the other logs to investigate the "Property not found" issue?

    I use session variables in all the apps I've worked on successfully. All web apps I might add.
    Mike Brown - Contact Me
    Programmatic Technologies, LLC
    Programmatic-Technologies.com
    Independent Developer & Consultant

  9. #9
    Member
    Real Name
    Sean OKelly
    Join Date
    Sep 2015
    Location
    Charleston, WV
    Posts
    205

    Default Re: Session variable question

    As long as you are still in-session....then session variables are great. Alpha does have capability of working out-of-session though, and that could be the issue (for example, an app that must work in disconnected mode). We are using Arguments more now as it's more consistent between application types (for example - you need something to work on mobile and web and want to reuse the component from within a different interface).

  10. #10
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,571

    Default Re: Session variable question

    A session variable should be treated no differently than any other type of variable. You cannot depend on them being available where you want it or when you want it. You must be diligent and test session variables whenever they are to be used. If they are not available or not set with a value you're expecting then your code takes steps to establish the variable or set their values.

    This only applies to web applications. Session variables should never, and need ever, be used in a mobile application.

  11. #11
    Member jgrannis's Avatar
    Real Name
    Jeff Grannis
    Join Date
    Apr 2016
    Location
    New Iberia, LA
    Posts
    339

    Default Re: Session variable question

    Concerning UX components, the user might use the application for awhile without doing any AJAX callback or any other call to the server. So after 15 or 20 minutes... you've lost your session and session variables. Not really an Alpha issue; it is just not a good idea to use session variables with larger, "single page" web/mobile apps where the users will "randomly" lose their sessions.

  12. #12
    Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,827

    Default Re: Session variable question

    Although you can build a web application without session variables there is no problem using them and they are very convenient. But you have to understand that they are tied to a particular user and that they will expire, appropriately, when the user's session expires (that is a good thing). A user's session is just based on their browser having hit the website, and is fundamentally independent of their logged-in status but you can tie those two things together in Security Framework so that when the user's session expires, they are also logged out. And, when a person logs out, the session variables are all destroyed. To me it would not make any sense to set a session variable other than for a logged in user. What is the purpose, it will expire when that user abandons their browser for the 'session timeout' period. In my largest web applications I have five session variables and the same ones in my smallest application. They are convenient, like setting session.fullname to the logged in user's name so I can display it here and there. But it is very important that this is tied to them being logged in and if by some mystery not related to their session timeout their session variables disappear (has never happened), I reset them to their proper values when the screen is refreshed. But again, they are tied to the user being logged in only.
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  13. #13
    Member
    Real Name
    Alan Sawyer
    Join Date
    Apr 2006
    Location
    western New York (rural)
    Posts
    261

    Default Re: Session variable question

    I think one of the issues with session variables is the following. Let's say a user logs into your app, and selects a particular company Id to work with, then wants to see the customers in that company. A session variable is set with the company id. All is good, but if the user opens another browser tab, logs in and selects a company to look at. The the session variable from the second tab overwrites the first tabs session variable.
    Am I confused about this?

    I would have thought that a different tab with a fresh login would have created separate session variables.

  14. #14
    Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,827

    Default Re: Session variable question

    Yes that is true, session vars are shared on the browser between tabs when on the samr application. They would even be shared if you were on two different Alpha applications, one in each tab. And, some people run multiple Alpha apps (on the same IP and port) using subfolders for each one where session vars from the app in /folder1 are shared with the app in /folder2.
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  15. #15
    "Certified" Alphaholic kkfin's Avatar
    Real Name
    Kenneth
    Join Date
    Dec 2006
    Location
    EU
    Posts
    1,520

    Default Re: Session variable question

    Yes and therefore we have possibility to run different instances of Application server in different ports and/or IP. With reverse proxy in front of Alpha the url is still myserver.com/app1 and myserver/app2. Or we can run them from different domain like myapp1.myserver.com and myapp2.myserver.com again using reverse proxy.

    Ken

  16. #16
    Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,827

    Default Re: Session variable question

    Yep, a reverse proxy front end fixes that. I use a load balancer and run a couple websites on a single IP but different ports. As an example, alphatogo.com goes to one set of ports while iadn.com goes to a different set of ports. I listen only on standard ports 80 and 443 so there is mo port number in the URL.
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

Similar Threads

  1. Replies: 0
    Last Post: 01-02-2019, 04:32 PM
  2. Replies: 13
    Last Post: 07-17-2014, 09:37 AM
  3. Session Variables as Date values in Array? Access Session Variable from Javascript ?
    By kimhere in forum Application Server Version 11 - Web/Browser Applications
    Replies: 3
    Last Post: 04-26-2013, 02:02 PM
  4. Session Variable Question
    By spmat in forum Alpha Five Version 9 - Desktop Applications
    Replies: 1
    Last Post: 01-28-2009, 01:18 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •