Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

How to set session variable and retrieve its value?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to set session variable and retrieve its value?

    Okay .. just read this post that tells me that all of the documentation I have been using is wrong:
    http://msgboard.alphasoftware.com/al...hlight=session

    And .. I also read these:
    http://wiki.alphasoftware.com/Applic...hanges+for+V11
    http://wiki.alphasoftware.com/Storin...n+Sessions+V11
    http://wiki.alphasoftware.com/Server...+V11#Request_3

    So the question is ..
    Where is the video that shows me how to do all of this now?

    For example:
    1. Web Security > External User ID Value; are we still calling this ulink?
    2. So if I want to retrieve data from my people table using that, should this still work?

    'CHECK USER STATUS
    cn = "::name::conn"
    table = "contact"
    filter = "id = '" + vUlink + "'"
    result = "inactive"

    inactive = sql_lookup(cn,table,filter,result)

    'NOTIFY THE USER THAT THEY ARE SUSPENDED
    if inactive = .T. then
    response.redirect("login_denied.a5w")

    else
    'GOTO APPROPRIATE STARTUP PAGE
    response.redirect("cus_console.a5w")
    end if

    %>

    #2
    Re: How to set session variable and retrieve its value?

    Betty,

    The External User ID Value can be named whatever you want. I used to call it session.__protected__ulink because that helped me remember where it came from and where it was set. But it can have any name. In future applications, I'll probably name it SESSION.USERID because thats usually the field I base it on.

    The session variable coming out of security has always been type character, so nothing in your example will have changed.

    As you know, SQL will typically change the type of a variable to suit what is needed, so your select, insert, and update statement may still work just fine.
    Pat Bremkamp
    MindKicks Consulting

    Comment


      #3
      Re: How to set session variable and retrieve its value?

      Thanks Pat .. and testing things .. with the underscores removed .. that appears to be true. I think that I, too, will use USERID instead of ULINK .. because my fingers want to type UNLINK no matter what I do.

      Comment


        #4
        Re: How to set session variable and retrieve its value?

        Do you know how I can SHOW the USERID / ULINK of the current logged in user?

        Comment


          #5
          Re: How to set session variable and retrieve its value?

          Code:
          <%A5 
          Dim vUser as c
          dim Request as p
          
          if eval_valid("session.__protected__ulink") 
              vUser = A5WS_Get_User_From_GUID(a5ws_Get_GUID_From_Ulink(session.__protected__ulink,Request),Request)
          else
              vUser = "ERROR: Not logged in!"
          end if
          
          ? vUser + " is logged in."
          %>
          Peter
          AlphaBase Solutions, LLC

          [email protected]
          https://www.alphabasesolutions.com


          Comment


            #6
            Re: How to set session variable and retrieve its value?

            Thanks Peter; works verbatim. But I am thrown off by a couple things:

            1) http://msgboard.alphasoftware.com/al...hlight=session. The way that I understand this is that I need to remove __protected__ from where every it is used; it is (from the wiki) "Session Variables cannot be created directly from a request query string or POST body. This negates the need to use "protected" session variables, as all session variables are now effectively "protected". "

            So .. if I remove __protected__ from your code - it no longer works.

            2) The other thing throwing me off is that I thought that '0' = .F. and '1' = .T. like a light switch; 0 is off and 1 is on. So if I check the box that I am calling 'inactive' (see my original code example above) then that would mean that inactive = true and the box is checked. So this statement should execute:

            if inactive = .T. then
            response.redirect("login_denied.a5w")

            It acts just the opposite. I created two dummy users. Checked the inactive box on one of them - and verified in mySQL that the value has indeed changed from 0 to 1. But the user whose value is 1 (.T.) can login .. while the user whose value is 0 (.F.) cannot.

            Does that make sense to you?

            Comment


              #7
              Re: How to set session variable and retrieve its value?

              Duh .. I re-read that thread .. "Just to reiterate Carol, nothing is going to suddenly break. You do not need to stop what you are doing to modify existing code. If you never move beyond V11's Xbasic web server, you will never need to make any changes. We are making customers aware of a potential future issue."

              So I guess it is not an issue at the moment .. but I thought that because I am just getting started here I need to understand this so that I do things the RIGHT way.

              Still confused that things are not what I think they should be (in example #2)

              Comment


                #8
                Re: How to set session variable and retrieve its value?

                And reading the wiki again .. this is why it doesn't work when I remove __protected__ .. "Session Variables cannot be created directly from a request query string"

                Comment


                  #9
                  Re: How to set session variable and retrieve its value?

                  I think I have two questions here .. started with one which led into the other.

                  Comment


                    #10
                    Re: How to set session variable and retrieve its value?

                    Originally posted by betty View Post
                    T The way that I understand this is that I need to remove __protected__ from where every it is used;
                    You don't need to remove __protected__ from your session vars, not now, not ever. But supposedly you have that option in v11. Haven't tried this yet. Don't have time for your other questions at the moment - it's getting late...
                    Peter
                    AlphaBase Solutions, LLC

                    [email protected]
                    https://www.alphabasesolutions.com


                    Comment


                      #11
                      Re: How to set session variable and retrieve its value?

                      Hold that thought! Never say Not ever
                      Originally posted by Lenny Forziati View Post
                      Just to reiterate Carol, nothing is going to suddenly break. You do not need to stop what you are doing to modify existing code. If you never move beyond V11's Xbasic web server, you will never need to make any changes.

                      We are making customers aware of a potential future issue. We suggest that all NEW code you write from now on uses only character variables. Additionally, if you do plan to move beyond V11's Xbasic web server, you should begin planning updates to existing code at a convenient time in your development cycle.
                      Chad Brown

                      Comment


                        #12
                        Re: How to set session variable and retrieve its value?

                        Originally posted by Peter.Greulich View Post
                        You don't need to remove __protected__ from your session vars, not now, not ever. But supposedly you have that option in v11. Haven't tried this yet. Don't have time for your other questions at the moment - it's getting late...
                        Originally posted by chadbrown View Post
                        Hold that thought! Never say Not ever

                        Originally posted by Lenny Forziati
                        Just to reiterate Carol, nothing is going to suddenly break. You do not need to stop what you are doing to modify existing code. If you never move beyond V11's Xbasic web server, you will never need to make any changes.

                        We are making customers aware of a potential future issue. We suggest that all NEW code you write from now on uses only character variables. Additionally, if you do plan to move beyond V11's Xbasic web server, you should begin planning updates to existing code at a convenient time in your development cycle.
                        You are mixing issues.

                        You do not ever need to remove __protected__ from your variable names. It is entirely necessary, but it there is nothing special about this naming convention in V11 that will break variables named this way, and they will not be broken in a future release either.

                        The possible issue to be aware of is session variables dimmed as any type other than C. These also will not break in V11, though it is possible that there will be a conflict when moving to IIS.

                        Lenny Forziati
                        Vice President, Internet Products and Technical Services
                        Alpha Software Corporation

                        Comment


                          #13
                          Re: How to set session variable and retrieve its value?

                          Originally posted by Lenny Forziati View Post
                          Though it is possible that there will be a conflict when moving to IIS.
                          That was my only point sorry if I confused everyone.
                          Chad Brown

                          Comment


                            #14
                            Re: How to set session variable and retrieve its value?

                            Thanks Lenny .. I did read that in another post ..

                            For anyone else who might read this .. this is my startup script (it seems to work okay so I assume I have things right here):

                            'DIM VARIABLES
                            DIM pUser as p '-- Used to get info about logged in user (options are guid, email, ulink, etc)
                            DIM vInactive as L = .f. 'User exists in security but is locked out for other reason (ie. credit hold)
                            DIM session.__protected__isAdministrator as L = .f.
                            DIM session.__protected__isEmployee as L = .f.
                            DIM session.__protected__isCustomer as L = .f.
                            DIM cn as C
                            DIM table as C
                            DIM filter as C
                            DIM result as C

                            'GET INFORMATION ABOUT THE CURRENTLY LOGGED IN USER
                            'a5ws_logged_in_user_values(pUser,request,session)
                            a5ws_logged_in_user_values(pUser)
                            group = a5ws_get_user_assignments(pUser.userid)

                            'INACTIVE USER
                            if variable_exists("pUser.ulink") then
                            cn = "::name::conn"
                            table = "contact"
                            filter = "id = '" + pUser.ulink + "'"
                            result = "inactive"

                            vcInactive = sql_lookup(cn,table,filter,result)

                            if vcInactive = .t. then
                            'USER CONTACT RECORD IS INACTIVE
                            response.redirect("login_denied.a5w")
                            else
                            'REDIRECT TO APPROPRIATE START PAGE
                            if "Employees" $ Group then
                            session.__protected__isEmployee as L = .t.
                            response.redirect("emp_console.a5w")
                            else
                            session.__protected__isClient as L = .t.
                            response.redirect("cus_console.a5w")
                            end if
                            end if
                            else 'No Ulink exists
                            response.redirect("login_denied.a5w")
                            end if

                            %>

                            Comment

                            Working...
                            X