Session variable usage?

M

McKirahan

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.
 
A

Aaron [SQL Server MVP]

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
%>
 
M

McKirahan

Ray Costanzo said:
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.
 
M

McKirahan

Aaron said:
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
%>

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 :)
 
A

Aaron [SQL Server MVP]

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..."
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top