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

Capture user info after login and store in session variable - web app

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

    Capture user info after login and store in session variable - web app

    Hello all.

    Made it 3 yrs without having to make a post. But now I am running out of time and patience on this problem. Here we go...

    Trying to capture information for the logged in user and store those values in session variables. I have set up the post login �process� page and set up the page redirect in security. The code I am currently using on the process page is derived from a response posted by Kieth Hubert on 12-24-2011. Here's the sheet music:

    <%a5
    dim tbl as p
    session.CurrentUserName = "wilma" 'a5ws_getcurrentuser()
    'Hard coded user name for testing purposes
    'Begin test code
    'test code modified from the message board > "How to reteive data after login for that particular user id?"

    tbl=table.open("org_empl")

    query.filter=("user_name=var->Sesssion.CurrentUserName")
    tbl.query_create()

    session.org_id=alltrim(tbl.org_id)
    session.first_name=alltrim(tbl.org_empl_first)
    session.last_name=alltrim(tbl.org_empl_last)

    tbl.query_detach()
    tbl.close()
    'End test code

    response.redirect("HomePage.a5w")
    %>

    When I run this it throws an error message that says:
    �Script: TEMPLATE line:9
    tbl.query_create()
    Cannot use function in this context�

    I have tried many other things trying to solve my issue with no success. Ideas??

    Thanks in advance!
    Rob

    #2
    Re: Capture user info after login and store in session variable - web app

    Rob,

    Wow 3 years without a question ... you are way more patient than me

    I'm not an expert by any means, but I'm doing the same thing as you are trying to accomplish, slightly differently.
    I don't see where you are declaring the session variable before using it, ie) dim session.CurrentUserName as c

    Have a look at my code, perhaps it might turn on a light bulb for you. Obviously your connection string and table names will be different.
    Code:
    <%a5
    'dim variables
    dim session.current_user_fname as c
    dim session.current_user_lname as c
    
    'get current user firstname & lastname
    cn = "::name::Engineering"
    table = "Employees"
    filter = "username = '" + a5ws_getCurrentUser() + "'"
    result_fname = "firstname"
    result_lname = "lastname"
    
    session.current_user_fname = sql_lookup(cn,table,filter,result_fname)
    session.current_user_lname = sql_lookup(cn,table,filter,result_lname)
    
    'send the logged-in user to the index page
    response.redirect("home.a5w")
    
    %>
    Stephen
    Alpha Anywhere v12.4.6.5.2 Build 8867-5691 IIS v10.0 on Windows Server 2019 Std in Hyper-V

    Comment


      #3
      Re: Capture user info after login and store in session variable - web app

      Stephen,

      Thanks for your response. Wish it had been 3 yrs without a question! Had plenty, just got the answers the hard way. Figured it may help the learning process. Anyway...

      Still unable to find my problem since I am using DBF and you are using SQL. There are syntax differences that I don't know since I have not worked with SQL yet. I am quite sure this is a syntax issue. Something simple that I have overlooked in setting up my query. Looks like SQL handles queries in a different way. Not sure why it is telling me "Cannot use function in this context" on the "tbl.query_create()."

      I have also tried:
      dim qry as p 'and then create the query with >
      qry=tbl.query_create()

      Still nothing! BTW...I have now dimmed all my variables even though I wasn't using "option strict" since it is better form to do so (I believe).

      Rob

      Comment


        #4
        Re: Capture user info after login and store in session variable - web app

        It's looking for your table in your webroot, where it probably isn't and shouldn't be. So, the server needs to know where it is:

        tbl=table.open("[pathalias.adb_path]\org_empl")

        This assumes you've correctly set that alias in your profile settings.
        -Steve
        sigpic

        Comment


          #5
          Re: Capture user info after login and store in session variable - web app

          Just to make sure that the path alias has been setup correctly, I made a completely new profile. Also changed the code on the process page to match:

          tbl=table.open("[pathalias.adb_path]\org_empl")

          Everything works fine through the login process until page redirect. Then I am issued the following:

          500 Internal Server Error
          Script Error
          Error:Script:" /a5AmnetProfile/Process_page.a5w" line:22
          tbl.query_create()
          Cannot use function in this context

          Not that I really have a clue, but it seems as though it doesn't like the "tbl.query_create()." Maybe it is a problem locating the table but that should be resolved now.

          Comment


            #6
            Re: Capture user info after login and store in session variable - web app

            Rob, I haven't used dbf for a while, but here is some code out of the processing page of an old V9 app

            <%a5
            '==== get the permission ids if logged in
            dim session.__protected__Username as c = DEFAULT ""
            dim session.__protected__AgencyId as c = DEFAULT "No"
            dim session.__protected__RealtorId as c = DEFAULT "No"
            dim session.__protected__DborId as c = DEFAULT "No"
            if eval_valid("session.__protected__UserId")=.t.
            dim ptbl as p
            ptbl=table.open("[PathAlias.ADB_Path]\people.dbf")
            ptbl.index_primary_put("Pe_Id")
            vFound=ptbl.fetch_find(session.__protected__UserId)
            if vFound>0
            session.__protected__UserName=alltrim(ptbl.lastname)+" "+alltrim(ptbl.firstname)
            session.__protected__AgencyId=ptbl.Agency
            session.__protected__RealtorId=ptbl.Realtor
            session.__protected__DborId=ptbl.Dbor
            end if
            ptbl.close()
            end if
            %>

            Now days with V11, you should use variable_exists() instead of eval_valid(), you don't need the "__protected__", do not dim the session variables and set them all up to be character, so there are some changes to make here.
            Pat Bremkamp
            MindKicks Consulting

            Comment


              #7
              Re: Capture user info after login and store in session variable - web app

              I hadn't looked through your code completely, but this probably needs to be changed to:

              query.filter=("user_name='" + var->Sesssion.CurrentUserName + "'")

              Pay close attention to the single and double quotes I have in there -- put it in Notepad and make it real big if you have to.
              -Steve
              sigpic

              Comment


                #8
                Re: Capture user info after login and store in session variable - web app

                Also, is this a typo?

                query.filter=("user_name=var->Sesssion.CurrentUserName")
                Alpha Anywhere v12.4.6.5.2 Build 8867-5691 IIS v10.0 on Windows Server 2019 Std in Hyper-V

                Comment


                  #9
                  Re: Capture user info after login and store in session variable - web app

                  A big thanks to all for the input. I made the change suggested by brother Workings -- query.filter=("user_name='" + var->Sesssion.CurrentUserName + "'") And yes, Stephen, Sesssion was a typo in the code and has been corrected since I'm sure that wasn't helping things! All seems to be working as intended at this point.

                  Thanks again for the help!
                  Rob

                  Comment


                    #10
                    Re: Capture user info after login and store in session variable - web app

                    Originally posted by iRadiate View Post

                    Have a look at my code, perhaps it might turn on a light bulb for you. Obviously your connection string and table names will be different.
                    Code:
                    <%a5
                    'dim variables
                    dim session.current_user_fname as c
                    dim session.current_user_lname as c
                    
                    'get current user firstname & lastname
                    cn = "::name::Engineering"
                    table = "Employees"
                    filter = "username = '" + a5ws_getCurrentUser() + "'"
                    result_fname = "firstname"
                    result_lname = "lastname"
                    
                    session.current_user_fname = sql_lookup(cn,table,filter,result_fname)
                    session.current_user_lname = sql_lookup(cn,table,filter,result_lname)
                    
                    'send the logged-in user to the index page
                    response.redirect("home.a5w")
                    
                    %>
                    Stephen
                    Stephen - you the man! ... light bulb came on!

                    This is EXACTLY what I was about to post here about but did a search of the forum first and voila!.

                    I was going through Steve Workings video on how to do this and add it to my app. Worked just fine as in the video, but I wanted to also have the Last Name. Now I do :)

                    Putting the following in the header area of the Tabbed UI and also in the text for the Logout button gives me precisely what I was looking to achieve:

                    Header
                    Code:
                    <%A5
                    
                    if a5ws_getcurrentuser() <> ""
                    	?"Logged in as: " + session.current_user_fname + " " + session.current_user_lname
                    end if
                    
                    %>
                    Button
                    Code:
                    Logout
                    <br>
                    <%A5
                    
                    if a5ws_getcurrentuser() <> ""
                    	?session.current_user_fname + " " + session.current_user_lname
                    end if
                    
                    %>
                    Cheers!
                    Lyle Chamney
                    http://www.2ninerniner2.com/
                    Websites rebuilt with WordPress
                    http://goodcheapfastwebsites.com/
                    Complete, ready to install WordPress websites
                    http://snifflevalve.com
                    WordPress training and tutorials

                    Comment

                    Working...
                    X