Session variable usage?

Discussion in 'ASP General' started by McKirahan, Mar 24, 2005.

  1. McKirahan

    McKirahan Guest

    Is there a way to use a Session Variable to prevent
    the successful resubmission of a form if the user
    uses the Back button and tries to submit it again?

    Thanks in advance.
     
    McKirahan, Mar 24, 2005
    #1
    1. Advertising

  2. Um, yeah. On the form page:

    <%
    if request.form("whatever") <> "" and not (session("already_submitted"))
    then
    ' do your thing with the data
    session("already_submitted") = true
    else
    ' form was empty, or already submitted
    end if
    %>

    --
    Please post DDL, sample data and desired results.
    See http://www.aspfaq.com/5006 for info.




    "McKirahan" <> wrote in message
    news:...
    > Is there a way to use a Session Variable to prevent
    > the successful resubmission of a form if the user
    > uses the Back button and tries to submit it again?
    >
    > Thanks in advance.
    >
    >
     
    Aaron [SQL Server MVP], Mar 24, 2005
    #2
    1. Advertising

  3. Yeah, you could do that if you want, I suppose.

    <% If Session("AlreadySubmitted") = "" Then %>
    <form method="post" action="yourpage.asp">
    <% Else %>
    Already submitted
    <% End If %>

    You'd want to use that in conjunction with anti-caching headers.

    http://www.aspfaq.com/show.asp?id=2017
    http://www.aspfaq.com/show.asp?id=2022

    Ray at work

    "McKirahan" <> wrote in message
    news:...
    > Is there a way to use a Session Variable to prevent
    > the successful resubmission of a form if the user
    > uses the Back button and tries to submit it again?
    >
    > Thanks in advance.
    >
    >
     
    Ray Costanzo [MVP], Mar 24, 2005
    #3
  4. McKirahan

    McKirahan Guest

    "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    message news:#...
    > Yeah, you could do that if you want, I suppose.
    >
    > <% If Session("AlreadySubmitted") = "" Then %>
    > <form method="post" action="yourpage.asp">
    > <% Else %>
    > Already submitted
    > <% End If %>
    >
    > You'd want to use that in conjunction with anti-caching headers.
    >
    > http://www.aspfaq.com/show.asp?id=2017
    > http://www.aspfaq.com/show.asp?id=2022
    >
    > Ray at work


    Thanks to all; especially Ray as it was the "anti-caching headers"
    approach that I needed.

    I misstated my problem as I had solved that one yesterday;
    I basically came up with Aaron's solution.

    Today's problem was, basically, how to prevent the user from
    backing in to a secure page after logging out.
     
    McKirahan, Mar 24, 2005
    #4
  5. McKirahan

    McKirahan Guest

    "Aaron [SQL Server MVP]" <> wrote in message
    news:...
    > Um, yeah. On the form page:
    >
    > <%
    > if request.form("whatever") <> "" and not

    (session("already_submitted"))
    > then
    > ' do your thing with the data
    > session("already_submitted") = true
    > else
    > ' form was empty, or already submitted
    > end if
    > %>
    >
    > --
    > Please post DDL, sample data and desired results.
    > See http://www.aspfaq.com/5006 for info.


    I wondered why you added:

    Please post DDL, sample data and desired results.
    See http://www.aspfaq.com/5006 for info.

    until I saw it was your response to "error message" so I'll ignore it :)
     
    McKirahan, Mar 24, 2005
    #5
  6. > I wondered why you added:
    >
    > Please post DDL, sample data and desired results.
    > See http://www.aspfaq.com/5006 for info.


    It's just my signature. Most of my time is spent in the SQL Server groups,
    where a gentle reminder is not enough to drive this point home. I figure
    the more exposure this page gets, the fewer questions we'll get that start
    with "I have this table with a couple of varchar columns..."

    --
    Please post DDL, sample data and desired results.
    See http://www.aspfaq.com/5006 for info.
     
    Aaron [SQL Server MVP], Mar 24, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. metfan
    Replies:
    2
    Views:
    4,852
    Robert Olofsson
    Oct 21, 2003
  2. Colin J. Williams

    Webchecker Usage - a problem with local usage

    Colin J. Williams, Feb 25, 2004, in forum: Python
    Replies:
    1
    Views:
    540
    Colin J. Williams
    Feb 26, 2004
  3. hvt
    Replies:
    0
    Views:
    1,212
  4. hvt
    Replies:
    0
    Views:
    1,474
  5. chowchho
    Replies:
    7
    Views:
    634
    Patrice
    Mar 28, 2008
Loading...

Share This Page