Create the three A5W pages listed below, all with the default Always Deny security access. Use a5w_include() to insert them where suggested for each of the three blocks of code.

This expects you have a normal Alpha login dialog sitting on an A5W page. If your login is integrated in to a UX, not sure what to do, but play with it. Please read the comments each script.

***USE AT YOUR OWN RISK - IT CAUSES YOUR WEB PAGE TO AUTO-LOGIN TO YOUR APPLICATION PRETTY MUCH DEFEATING LOGIN SECURITY FOR THAT APP. YOU COULD RESTRICT IT TO YOUR OWN IP OR COMPUTER WITH ADDITIONAL CODE.***

Insert the scripts below into your existing A5W pages using this syntax:

a5w_include(“inc_set_login_cookie.a5w”)


inc_set_login_cookie.a5w
<%a5
'== This script goes at the top of the page that has the login dialog.
'== You MUST set the encryption key "mykey" to your own value

'==HTTPCookie reference: http://msdn.microsoft.com/en-us/libr...v=vs.110).aspx
'==the .Expires value should be a date in the future rather than a unit of time (seconds, minutes, etc.)
'==E.g., now() + 1000 is 1000 SECONDS from NOW
'==Multiplied by 60 -- 6 hrs = 360, 1 day = 720, 1 week = 10800, 1 month = 263,520

'== determine if logged in, SKIP entire process if already logged in
dim pUser as p
dim pUser.userid as c
A5WS_Logged_In_User_Values(pUser)
if pUser.userid = "" ' not logged in
if variable_exists("login_cookie") = .f.
'==get login values
if variable_exists("submitbutton")
dim userid as c
dim password as c
cookie_value = userid + "|" + password
'encrypt
cookie_value = encrypt_string(cookie_value,"mykey")
'==set cookie
dim cookie_expires_seconds as n = 10800 ' set this value
dim LoginCookie as System::Web::HttpCookie = new System::Web::HttpCookie("login_cookie")
LoginCookie.Expires = now() + cookie_expires_seconds * 60
LoginCookie.Value = cookie_value
LoginCookie.HTTPOnly = .t.
response.cookies.add(LoginCookie)
end if
end if
end if
%>

inc_auto_login.a5w
<%a5

'==This script goes at the top of all pages in your app, or you home page, or a "header" page that sits on top of all pages
'== The encryption key "mykey" must match the one in inc_set_login_cookie.a5w

'==HTTPCookie reference: http://msdn.microsoft.com/en-us/libr...v=vs.110).aspx
'==the .Expires value should be a date in the future rather than a unit of time (seconds, minutes, etc.)
'==E.g., now() + 1000 is 1000 SECONDS from NOW
'==Multiplied by 60 -- 6 hrs = 360, 1 day = 720, 1 week = 10800, 1 month = 263,520

'== determine if logged in, SKIP entire process if already logged in
dim pUser as p
dim pUser.userid as c
A5WS_Logged_In_User_Values(pUser)
if pUser.userid = "" ' not logged in
if variable_exists("login_cookie")
'decrypt
cookie_value = decrypt_string(login_cookie,"mykey")
username = word(cookie_value,1,"|")
password = word(cookie_value,2,"|")
a5ws_login_user(username,password)
end if
end if
%>

inc_del_login_cookie.a5w
<%a5

'== This script goes at the top of the logout.a5w page and removes the login_cookie because they explicitly logged out.

if variable_exists("login_cookie")
'==set cookie
dim LoginCookie as System::Web::HttpCookie = new System::Web::HttpCookie("login_cookie")
LoginCookie.Expires = now()
LoginCookie.Value = ""
LoginCookie.HTTPOnly = .t.
response.cookies.add(LoginCookie)
end if
%>