View Full Version : Checking if the session ends on the form submit
telmessos
08-28-2008, 09:56 PM
Hi All,
I have a form and it is going to a bank's secure credit card payment service. According to the reply coming from that system my code is writing the information kept in the session to the database or not. When the client submits the form I want a script check if the session time out passed. If it is passed instead of submitting the form give a warning. If not, proceed.
Any idea?
Thanks
telmessos
brazenskies
08-28-2008, 10:02 PM
if session("sessionName") = "" then
do this
else
do this
end if?
telmessos
08-28-2008, 10:06 PM
thank you for the information. I don't know how to call this when the form submitted. let's say a client came to the form and left the page open for more then 20 mins. The session ends but they still can submit the form. Right?
If the session ends I have to stop them submit the form.
Spudhead
08-29-2008, 10:40 AM
Make your form submit to an intermediate page on your server. This page collects all the form fields you've just posted to it, checks the session - see brazenskies code - and forwards them on to the bank if it's ok. To forward them on you could either make your intermediate page write out a HTML form that submits itself immediately when it loads - although that's not the most elegant solution - or possibly create an XMLHTTP request.
telmessos
08-29-2008, 11:13 AM
Hi Spudhead,
Thank you for the reply. Do you have an example for self submitting form ?
Thanks
Spudhead
08-29-2008, 12:12 PM
<form id="foo">
....
</form>
<script type="text/javascript">
function myfunc () {
var frm = document.getElementById("foo");
frm.submit();
}
window.onload = myfunc;
</script>
brazenskies
08-29-2008, 01:51 PM
I'd just submit the form, then check to see if the session is active before doing anything else.
If the session has ended then show a message to let them know, otherwise process the form.
Edit, sorry I'm blind...
This page collects all the form fields you've just posted to it, checks the session - see brazenskies code - and forwards them on to the bank if it's ok.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.