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

After User registers, pick up username as session variable

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

    After User registers, pick up username as session variable

    I have a page with a simple user registration on it. On Submit, I'd like the user to be redirected to another page (I got this part) WITH the username as a session variable. I have a feeling that defining the session variable using a5ws_getCurrentuser() would not work, since the user is technically not logged in. Any ideas on this one?

    Thanks!

    #2
    Re: After User registers, pick up username as session variable

    I'm applying my desktop experience here, so if it is out of line, I'm sorry.

    Can't you just define a global variable when you open the APP , then assign the user sign-in name to the variable. If you define it as global, you should be able to see it anywhere. Just place the variable on the next page.
    Last edited by Tom Henkel; 07-10-2013, 08:09 PM.

    Comment


      #3
      Re: After User registers, pick up username as session variable

      Scott,

      I'm not sure it's exactly the same thing but when I have a user login, I redirect to an intermediate page where I can set the session variables, then redirect to where they are supposed to go after that. I can't see why it wouldn't work in your case. An interim page with code something like this:

      Code:
      <%a5
      'dim variables
      dim session.current_user_fname as c
      dim session.current_user_lname as c
      dim session.current_user_email as c
      
      'get current user firstname & lastname
      cn = "::name::Engineering"
      table = "Employees"
      filter = "username = '" + a5ws_getCurrentUser() + "'"
      result_fname = "firstname"
      result_lname = "lastname"
      result_email = "email"
      
      session.current_user_fname = sql_lookup(cn,table,filter,result_fname)
      session.current_user_lname = sql_lookup(cn,table,filter,result_lname)
      session.current_user_email = sql_lookup(cn,table,filter,result_email)
      
      'send the logged-in user to the index page
      response.redirect("home.a5w")
      
      %>
      Alpha Anywhere v12.4.6.5.2 Build 8867-5691 IIS v10.0 on Windows Server 2019 Std in Hyper-V

      Comment


        #4
        Re: After User registers, pick up username as session variable

        Thank you both, much appreciated. Stephen, I think its close, but my problem is that the user is not logged in yet. In order to get the a5ws_getCurrentUser() I need them to be logged in. By the way, can't you put your code directly on the login page, rather than have an intermediate page? I think Jerry Brightbill has an article on that.

        Comment


          #5
          Re: After User registers, pick up username as session variable

          Originally posted by Scott B View Post
          Stephen, I think its close, but my problem is that the user is not logged in yet. In order to get the a5ws_getCurrentUser() I need them to be logged in.
          This is not true, if you have security on the page and you can get to it, then you are logged in. The example I showed above is working code from my application on a page called Login_Processing.a5w. This gets the username from the login page and gets the users firstname & lastname from my SQL database and assigns them to session variables. Then I redirect to my home page called home.a5w where I display the logged in user firstname & lastname in the header. Obviously if you just want username only, you can get away with something much simpler. Something like this should work:

          Code:
          dim session.current_username as c
          
          session.current_username = a5ws_getCurrentUser()
          
          response.redirect("home.a5w")
          Originally posted by Scott B View Post
          By the way, can't you put your code directly on the login page, rather than have an intermediate page? I think Jerry Brightbill has an article on that.
          I don't know, probably, I have never seen Jerry's article. I was taught to use an intermediate page. The main page of most apps can get quite messy with lots of code. It is much neater and easier to maintain, imho, to gather this information right after login using a single login processing page. Besides, the user doesn't see anything and doesn't know any different. They just think they're logging straight in to the app. It's entirely your choice, just trying to give you options.
          Alpha Anywhere v12.4.6.5.2 Build 8867-5691 IIS v10.0 on Windows Server 2019 Std in Hyper-V

          Comment


            #6
            Re: After User registers, pick up username as session variable

            Stephen, this is extremely helpful. Thank you very much.

            Comment


              #7
              Re: After User registers, pick up username as session variable

              Here is another thought.

              I have the code below in a small file called header.a5w. Then every A5W page of my app has this this xbasic code included: a5w_include("header.a5w") which is placed just after the <html>
              <head> <%a5 This is loaded then and run on each page. This allows some things to happen on each page call.

              Checks to see if a valid user is on the page, if not they are directed to the log in page. If the session timed out, the user is directed to the login page. If the user just logged in and doesn't have the required session variables set up yet, (in the example it checks for the variable "session.__protected__district") then it will run the xbasic code to get the required session variables. If the required variable is valid, then the routine just ends.

              Since my app also displays the user name and and a 'logout' link this a good place to add that for display at the top of the page. Some users can change their district code, so if they do, then the display is changed as well. Since this routine checks for valid variables, it is does not affect performance for a valid logged in user.

              Mike


              ''check to see if a user is logged in. If not then goto login page
              userid = a5ws_getcurrentuser()

              If userid = "" then
              a5ws_logoutuser(session,request,response)
              session.reset()
              response.redirect("index.a5w")
              end
              end if

              'if user session variable is not blank then end this process
              if eval_valid("session.__protected__district") then
              'display user name and district code with logout link, allows for change in district code if the user changed it.
              ? "Logged in: " + session.fullname + " " + session.__protected__district + "<a href=\"Logout.a5w\">(Logout)</a> "
              goto quit
              end if

              'routine here to get user session variables for newly logged in user
              dim cn as SQL::Connection
              dim args as SQL::Arguments
              ...routine to get user info for session variables
              ...


              quit:
              Mike Reed
              Phoenix, AZ

              Comment


                #8
                Re: After User registers, pick up username as session variable

                Session variables are always available you dont have to be logged into the system to use them every visit creates a session folder.
                When the user submits the grid set the datasubmitted to some session variables and use them where ever you want. sort of like this

                after insert

                session.username = datasubmitted.name

                then put ?session.username inside some a5code on your page.
                Chad Brown

                Comment


                  #9
                  Re: After User registers, pick up username as session variable

                  Stephen, you may have been taking this from some older stuff so I am sure you already know this but there is no need to dim session variables now.
                  Chad Brown

                  Comment


                    #10
                    Re: After User registers, pick up username as session variable

                    Originally posted by chadbrown View Post
                    Stephen, you may have been taking this from some older stuff so I am sure you already know this but there is no need to dim session variables now.
                    Thanks Chad, I didn't know that, or I did and forgot. Yeah, this is code dating back to v10.
                    Alpha Anywhere v12.4.6.5.2 Build 8867-5691 IIS v10.0 on Windows Server 2019 Std in Hyper-V

                    Comment


                      #11
                      Re: After User registers, pick up username as session variable

                      Hi Chad
                      "then put ?session.username inside some a5code on your page."
                      Sorry for been slow...
                      Understood the first part of you commend.
                      Can you please explain the above, perhaps with an example?

                      Many thanks
                      Tasos

                      Comment


                        #12
                        Re: After User registers, pick up username as session variable

                        <%a5
                        ?session.username
                        %>

                        The above code would need to be included wherever you would want the username to show up.
                        Chad Brown

                        Comment

                        Working...
                        X