Alpha Video Training
Results 1 to 21 of 21

Thread: get session variable from grid to html page

  1. #1
    "Certified" Alphaholic richard2007's Avatar
    Real Name
    Richard Harris
    Join Date
    Sep 2007
    Location
    Ashford, Kent, UK
    Posts
    1,095

    Default get session variable from grid to html page

    i have a grid with a link field, which opens another grid and sets session variables at the same time.

    i need to use one of the session variables on another html page using <%A5 ?session.client%>.

    the value wont show, do i need to do something to make the session variable created by the grid available to the HTML page?

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

    Default Re: get session vaiabler from grid to html page

    Hey Richard,

    I believe if you want to use session variables in a page then it needs to be an a5w page - pretty much the same as an HTML page - but with an a5w extension. This is the code from a simple, new, blank a5w page. I pasted the code into the page to show the session variable I set in the calling grid.

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta name="generator" content="Alpha Five HTML Editor Version 10 Build 4351-3710">
    <!-- must use in order to make XP Themes render -->
    <meta HTTP-EQUIV="MSThemeCompatible" content="Yes" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    
    <%a5
    If eval_valid("session.client")
      ?session.client
    End If
    %>
    
    <title></title>
    </head>
    <body>
    <p>&nbsp;</p>
    </body></html>

  3. #3
    "Certified" Alphaholic richard2007's Avatar
    Real Name
    Richard Harris
    Join Date
    Sep 2007
    Location
    Ashford, Kent, UK
    Posts
    1,095

    Default Re: get session vaiabler from grid to html page

    sorry, my mistake. the page is of course an .a5w page. i meant a page with no grids in, just a bit of xbasic.

  4. #4
    "Certified" Alphaholic richard2007's Avatar
    Real Name
    Richard Harris
    Join Date
    Sep 2007
    Location
    Ashford, Kent, UK
    Posts
    1,095

    Default Re: get session vaiabler from grid to html page

    this is the link that opens a grid and sets session variables

    Code:
    cust_wait.a5w?session.caseref={Caseref}&session.clientemail={Clientemail}&session.clientname={Client1}&session.adviser={Adviser}

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

    Default Re: get session vaiabler from grid to html page

    An aside, setting a session variable in the URL is among the most security-foolish things you can do.
    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)

  6. #6
    "Certified" Alphaholic richard2007's Avatar
    Real Name
    Richard Harris
    Join Date
    Sep 2007
    Location
    Ashford, Kent, UK
    Posts
    1,095

    Default Re: get session vaiabler from grid to html page

    Quote Originally Posted by Steve Wood View Post
    An aside, setting a session variable in the URL is among the most security-foolish things you can do.
    this is set on a page which only our staff can access who have authority to all data. i am working on setting them another way.

  7. #7
    "Certified" Alphaholic richard2007's Avatar
    Real Name
    Richard Harris
    Join Date
    Sep 2007
    Location
    Ashford, Kent, UK
    Posts
    1,095

    Default Re: get session vaiabler from grid to html page

    ok, i got this to set the session variable, my error the URL was working fine.

    i now want to use the value when it is available but use some text if the value is not available. i have tried to use this, but first im not sure if it will work and secondly if it will, obviously the syntax is incorrect as im getting an error 'expected value'

    Code:
    <%A5 iif(eval_valid(session.clientname),?session.clientname,"No Client Selected")%>

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

    Default Re: get session vaiabler from grid to html page

    I would use if then else. On the iif statement you're missing the "?" in front of the "No client" message, and no quotes around the session.clientname - but it still doesn't work. If then else works.

    <%a5
    If eval_valid("session.clientname")
    ?session.clientname
    else
    ?"No Client Selected"
    End If
    %>
    Last edited by Davidk; 06-29-2011 at 09:53 AM.

  9. #9
    "Certified" Alphaholic
    Real Name
    Scott
    Join Date
    Mar 2010
    Location
    Toronto,ON
    Posts
    1,031

    Default Re: get session vaiabler from grid to html page

    Quote Originally Posted by richard2007 View Post
    ok, i got this to set the session variable, my error the URL was working fine.

    i now want to use the value when it is available but use some text if the value is not available. i have tried to use this, but first im not sure if it will work and secondly if it will, obviously the syntax is incorrect as im getting an error 'expected value'

    Code:
    <%A5 iif(eval_valid(session.clientname),?session.clientname,"No Client Selected")%>
    <%A5 ?if(eval_valid("session.clientname"),session.clientname,"No Client Selected")%>
    Scott Moniz - Computer Programmer/Analyst
    REA Inc.
    http://reainc.net
    (416)-533-3777
    scott@reainc.net

    REA INC offers consulting services, programming services, systems design, database design, third party payment gateway integration (CHASE, PAYPAL, AUTHORIZE.NET) and developer support.
    If you need custom code, or 1-to-1 mentoring in any facet of your database/web application design,
    contact us to discuss options.

  10. #10
    "Certified" Alphaholic
    Real Name
    Scott
    Join Date
    Mar 2010
    Location
    Toronto,ON
    Posts
    1,031

    Default Re: get session vaiabler from grid to html page

    Quote Originally Posted by Steve Wood View Post
    An aside, setting a session variable in the URL is among the most security-foolish things you can do.
    +1
    Scott Moniz - Computer Programmer/Analyst
    REA Inc.
    http://reainc.net
    (416)-533-3777
    scott@reainc.net

    REA INC offers consulting services, programming services, systems design, database design, third party payment gateway integration (CHASE, PAYPAL, AUTHORIZE.NET) and developer support.
    If you need custom code, or 1-to-1 mentoring in any facet of your database/web application design,
    contact us to discuss options.

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

    Default Re: get session vaiabler from grid to html page

    Quote Originally Posted by aburningflame View Post
    <%A5 ?if(eval_valid("session.clientname"),session.clientname,"No Client Selected")%>
    Thanks Scott... never would have got that one.

  12. #12
    "Certified" Alphaholic
    Real Name
    Scott
    Join Date
    Mar 2010
    Location
    Toronto,ON
    Posts
    1,031

    Default Re: get session vaiabler from grid to html page

    No problem.

    Basically if() returns a C character.
    So you could do this
    dim clientname as C=if(condition,"Hello","No Client Selected")
    ?clientname

    but the shortform is
    ?if(condition,"Hello","No Client Selected")

    Same as doing:
    ?alltrim(myvar) or whatever
    Youre basically printing the return value of the if statement

    As a side note:
    eval_valid expects a string.
    eval_valid(session.var) is incorrect, eval_valid("session.var") is correct
    Scott Moniz - Computer Programmer/Analyst
    REA Inc.
    http://reainc.net
    (416)-533-3777
    scott@reainc.net

    REA INC offers consulting services, programming services, systems design, database design, third party payment gateway integration (CHASE, PAYPAL, AUTHORIZE.NET) and developer support.
    If you need custom code, or 1-to-1 mentoring in any facet of your database/web application design,
    contact us to discuss options.

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

    Default Re: get session variable from grid to html page

    And "if" and "iif" both work.

  14. #14
    "Certified" Alphaholic richard2007's Avatar
    Real Name
    Richard Harris
    Join Date
    Sep 2007
    Location
    Ashford, Kent, UK
    Posts
    1,095

    Default Re: get session variable from grid to html page

    thanks for both your help. both ways will show the value of the session variable once it has been set but they wont show the alternate text when no value is in the variable.

    any further ideas?

    thanks

  15. #15
    "Certified" Alphaholic richard2007's Avatar
    Real Name
    Richard Harris
    Join Date
    Sep 2007
    Location
    Ashford, Kent, UK
    Posts
    1,095

    Default Re: get session variable from grid to html page

    i think eval_valid is checking for the session variable and disregards whether it has a value or not as i tried this and it works great. i dont know much about all this so please let me know if i am likely to encounter problems with this method.

    Code:
    <%a5
    If session.clientname>"" then
    ?session.clientname
    else
    ?"No Client Selected"
    End If
    %>

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

    Default Re: get session variable from grid to html page

    If you mean for instance that Davids "<%A5 ?if(eval_valid("session.clientname"),session.clientname,"No Client Selected")%>" does not display anything, its because your session var does exist, but is blank.

    Try:

    dim session.clientname as c ' so it DOES exist, of you can dim it somewhere else as long as you guarantee it is dimmed by time it gets to this spot.
    ?if(session.clientname="",session.clientname,"No Client Selected")

    At least do this:
    cust_wait.a5w?cr={Caseref}&cl={Clientemail}&cn={Client1}&ad={Adviser}
    And then on the target A5W page use xbasic to save cr, cl, cn and ad to their respective session vars.
    That is one small step safer, not much.
    This would be better but more work to encrypt and decrypt:
    cust_wait.a5w?c=m%3cZ%3ae%26h7%60%2c%7f%27%5cMc%3aK%5cb%22%2da%7b%7b%7e%29x%40L1B%2da%2eg%23h%3e%3bsxoB

    Couple other points:

    - You say you want to display session.client, but session.client is NOT set by your URL. In case you have a typo on your A5W page or URL code.
    - Your 'clientemail' field is going to have a @ special character in it.
    - If adviser and client1 are common names, they may have embedded spaces and special characters. Spaces, special characters, should be encoded if they have to be included 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)

  17. #17
    "Certified" Alphaholic richard2007's Avatar
    Real Name
    Richard Harris
    Join Date
    Sep 2007
    Location
    Ashford, Kent, UK
    Posts
    1,095

    Default Re: get session variable from grid to html page

    Try:

    dim session.clientname as c ' so it DOES exist, of you can dim it somewhere else as long as you guarantee it is dimmed by time it gets to this spot.
    ?if(session.clientname="",session.clientname,"No Client Selected")
    thanks

    At least do this:
    cust_wait.a5w?cr={Caseref}&cl={Clientemail}&cn={Client1}&ad={Adviser}
    And then on the target A5W page use xbasic to save cr, cl, cn and ad to their respective session vars.
    That is one small step safer, not much.
    will do, i already have a page like this for the client side of the app so that they can not see the value int he url, the cust_wait page then redirects to the page they are expecting to see. i had already set the url in the grid and just wanted to test to see if i could achieve what i have been working on here first.

    - You say you want to display session.client, but session.client is NOT set by your URL. In case you have a typo on your A5W page or URL code.
    typo

    Your 'clientemail' field is going to have a @ special character in it.
    ok, another one to work on, didnt realise this, hopefully this will be negated once i have set the values differently.

    thanks for all the help, this is working great now.

  18. #18
    "Certified" Alphaholic richard2007's Avatar
    Real Name
    Richard Harris
    Join Date
    Sep 2007
    Location
    Ashford, Kent, UK
    Posts
    1,095

    Default Re: get session variable from grid to html page

    ok, now i want to add a link to the session variable part of the only. the link had encompassed the whole code which if there was no client, directed the client to a page with no data.

    so i need only to link the part of the code with a session variable, i have tried lots of different ways, what i have so far, but shows the value of session.clientname instead of the actual variable value

    Code:
    <%a5
    										If session.clientname>"" then
    										?<a href="st_caseoverview.a5w">session.clientname</a>
    										else
    										?"No Client"
    										End If
    									%>
    i have tried variations to this, but i am guessing all the time.

    PS - what i have learned today is going to help me a lot with another part of my app.

  19. #19
    "Certified" Alphaholic
    Real Name
    Scott
    Join Date
    Mar 2010
    Location
    Toronto,ON
    Posts
    1,031

    Default Re: get session variable from grid to html page

    <%a5
    If session.clientname<>"" then
    ?"<a href=\"st_caseoverview.a5w\">"+session.clientname+"</a>"
    else
    ?"No Client"
    End If
    %>
    Scott Moniz - Computer Programmer/Analyst
    REA Inc.
    http://reainc.net
    (416)-533-3777
    scott@reainc.net

    REA INC offers consulting services, programming services, systems design, database design, third party payment gateway integration (CHASE, PAYPAL, AUTHORIZE.NET) and developer support.
    If you need custom code, or 1-to-1 mentoring in any facet of your database/web application design,
    contact us to discuss options.

  20. #20
    "Certified" Alphaholic
    Real Name
    Scott
    Join Date
    Mar 2010
    Location
    Toronto,ON
    Posts
    1,031

    Default Re: get session variable from grid to html page

    You want to use eval valid all the time.
    And then check for the value.

    Another option is to use steves approach and dim session variables, but I like this approach better. (Why declare session variables if they dont need to be there in the first place? - I dont know) its a matter of preference i guess.

    Final Code:
    Code:
    IF eval_valid("session.clientname") then
          if session.clientname<>"" then
                ?"<a href=\"st_caseoverview.a5w\">"+session.clientname+"</a>"
          else
                 ?"No Client Selected"
          end if
    else
           ?"No Client Selected"
    end if
    Last edited by aburningflame; 06-29-2011 at 01:31 PM.
    Scott Moniz - Computer Programmer/Analyst
    REA Inc.
    http://reainc.net
    (416)-533-3777
    scott@reainc.net

    REA INC offers consulting services, programming services, systems design, database design, third party payment gateway integration (CHASE, PAYPAL, AUTHORIZE.NET) and developer support.
    If you need custom code, or 1-to-1 mentoring in any facet of your database/web application design,
    contact us to discuss options.

  21. #21
    "Certified" Alphaholic richard2007's Avatar
    Real Name
    Richard Harris
    Join Date
    Sep 2007
    Location
    Ashford, Kent, UK
    Posts
    1,095

    Default Re: get session variable from grid to html page

    perfect - thanks scott.

Similar Threads

  1. pass page name to session variable
    By Tbrondolo in forum Application Server Version 10 - Web/Browser Applications
    Replies: 1
    Last Post: 06-16-2011, 09:01 AM
  2. how to transfer session.variables between Javascript on HTML-page?
    By René Stout in forum Application Server Version 10 - Web/Browser Applications
    Replies: 5
    Last Post: 05-25-2011, 07:24 AM
  3. Filter grid using session variable
    By Alexandrus in forum Application Server Version 9 - Web/Browser Applications
    Replies: 1
    Last Post: 07-16-2008, 05:55 AM
  4. Session variable through Grid component
    By Dannie Mogensen in forum Web Application Server v6
    Replies: 3
    Last Post: 07-30-2007, 12:10 AM
  5. Filtering a Grid with a Session Variable
    By jeff_schneidr in forum Web Application Server v7
    Replies: 2
    Last Post: 12-02-2005, 09:28 AM

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
  •