Akira Dawson
Akira Dawson

Reputation: 1267

access vbscript session variable using javascript

in a bit of a pickle.

The aim is to remember the date a user picked. Process being:

They select date (e.g march 7th 2014) and click next (page 2). On the page 2 the date they select becomes a session variable

Dim bookStart
bookStart = request.form("start")
'manipulate bookstart for everything else
session("selectedDate") = bookStart

The user then decides they want to go back a page (page 1) and select another date instead so they click back. My problem is the session variable i displayed on page 1 is nothing and I don't know why. Here is a snippet in my document.ready and a part of the form(for page 1):

if(!$('#selectedDate').val() == null || !$('#selectedDate').val() == ""){
    alert("there's something in here, lets display it: "+$('#selectedDate').val());
}
else if (dateCounter == null){
    var current = new Date();
    dateChange(current, "", 0);
    dateCounter = 0;
}

<input type="hidden" id="selectedDate" value="<%=session("selectedDate")%>">

The if statement works that if the value is empty in the hidden input field, load the page with todays date! Please help!!

Upvotes: 0

Views: 595

Answers (1)

Akira Dawson
Akira Dawson

Reputation: 1267

I'm the biggest idiot in the world. Turns out if page 1 is on HTTP and page 2 is HTTPS, you won't be able to access session variables between the 2. So I just make page 1 secure and things just worked!

Upvotes: 1

Related Questions