Link to home
Start Free TrialLog in
Avatar of garethtnash
garethtnashFlag for United Kingdom of Great Britain and Northern Ireland

asked on

VBScript Help

Hi All,

I'm building a script that runs if a checkbox is checked, however currently it is running regardless of whether the checkbox is checked or not. It also creates secure cookies, from variables, but instead of the variables showing i see the variable names??

Here are the lines of code in question -

		        If NOT IsNull(request("SignInRememberMe")) Then
				Dim ValuetoHash
				ValuetoHash = arrLogin(1,candlogin) & arrLogin(2,candlogin) & arrLogin(3,candlogin)
				Dim HashValue 
				HashValue = sha256(ValuetoHash)
				
				Response.AddHeader "Set-Cookie", "(""cookie"")(""Authentication"")=sha256(ValuetoHash); path=/; HttpOnly" 
				Response.AddHeader "Set-Cookie", "(""cookie"")(""LoggedIn"")=Date; path=/; HttpOnly" 
				Response.Cookies("JobsterUK").Expires = dateAdd("d", 365, Now())		        
		    	end if
				result = 3        		    
			end if

Open in new window


When i view the cookies i get sha256(ValuetoHash) and Date

What am i doing wrong?

Thanks
Avatar of Big Monty
Big Monty
Flag of United States of America image

try

 If NOT IsNull(request("SignInRememberMe")) and request("SignInRememberMe") <> "" Then
	Dim ValuetoHash
	ValuetoHash = arrLogin(1,candlogin) & arrLogin(2,candlogin) & arrLogin(3,candlogin)
	Dim HashValue 
	HashValue = sha256(ValuetoHash)
				
	Response.AddHeader "Set-Cookie", "(""cookie"")(""Authentication"")=" & sha256(ValuetoHash) & "; path=/; HttpOnly" 
	Response.AddHeader "Set-Cookie", "(""cookie"")(""LoggedIn"")=" & Date & "; path=/; HttpOnly" 
	Response.Cookies("JobsterUK").Expires = dateAdd("d", 365, Now())		        
	end if
	result = 3        		    
end if

Open in new window

Avatar of garethtnash

ASKER

Hi Big Monty,

Unfortunately the first part isn't working, now regardless of whether the checkbox is checked or not, the scripts don't run.

The element in the form is

<input type="checkbox" name="rememberme" id="SignInRememberMe" value="true" checked="checked" form="SignIn">

Open in new window


The second part works great, except I'm trying to ensure the cookies remain for 365 days, so the code now looks like

Response.AddHeader "Set-Cookie", "(""Domain"")(""Authentication"")= " & HashValue & "; expires=" & CookieDate & "; domain=www.domain.co.uk; path=/; HttpOnly" 
				Response.AddHeader "Set-Cookie", "(""Domain"")(""LoggedIn"")=" & Date & "; expires=" & CookieDate & "; domain=www. Domain.co.uk; path=/; HttpOnly" 

Open in new window


I have created CookieDate further up in the script as

Dim CookieDate
				CookieDate = dateAdd("d", 365, Now())

Open in new window


When I run this, with the original opening If statement, the cookies get created, as secure HTTPOnly, with the domain name, but no expiry date -> if i close the browser and reopen the cookies are gone?

Help!

Thanks
Update, I've got the opening If statement working now,

But

Response.AddHeader "Set-Cookie", "(""Domain"")(""Authentication"")= " & HashValue & "; expires=" & CookieDate & "; domain=www.domain.co.uk; path=/; HttpOnly" 
				Response.AddHeader "Set-Cookie", "(""Domain"")(""LoggedIn"")=" & Date & "; expires=" & CookieDate & "; domain=www. Domain.co.uk; path=/; HttpOnly"

Open in new window


Is not creating any cookies...

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Big Monty
Big Monty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thank you