User Specific Redirects from Stand Alone Login Screens
Stand Alone Login Screens (HTML DataPages) can be a great asset for authenticated apps. Not only can they be placed directly on the homepage providing a single point of login, but you can also customize where the user will be directed based on data stored in their user profile. This article shows some examples of popular redirection techniques using an HTML DataPage, authentication parameters and sample JavaScript.

Redirect based on field value
Probably the most common redirect is based on user type. For example, if the user is an administrator the user is directed to the admin dashboard/portal/interface. If the user is a staff member then the user is directed to the staff member dashboard/portal/interface.
To implement this functionality, create an HTML DataPage in your authenticated folder. Make sure that advanced features and parameters are enabled. Copy and paste the following JavaScript sample into your HTML page.
if("[@authfield:Position]" == "Manager"){
window.location = "http://www.mysite.com/manager.html";
}
else if ("[@authfield:Position]" == "Staff"){
window.location = "http://www.mysite.com/staff.html";
}
else{
window.location = "http://www.mysite.com/other";
}
</script>
Replace the parameter name and values to match your app. You can duplicate the “else if” section as many times as necessary to accommodate the number of user groups in your app.
In this example we see there are two user group types (Manger and Staff) and also a catch all group which directs to “Other” if no Position value is found.
Redirect Based on Subscription Date
Another popular reason to redirect users is based on their subscription date or date of last confirmed payment. Using this method, past due users can be automatically directed away from protected areas of your app and towards payment information.
var today =new Date();
var signup = new Date( "[@authfield:Last_Payment]" );
var valid = new Date();
valid.setDate(today.getDate()-30);
if (valid<signup)
{
/*Valid*/
document.location = "http://www.mysite.com/menu.html";
}
else
{
/*Not Valid*/
window.location = "http://www.mysite.com/payment.html"
}
</script>
In this example, if the user’s last confirmed payment was received more than 30 days ago, the user will be directed to a payment page. This same basic system can also be used to direct users who haven’t logged in for extended periods of time, or who are logging in for the first time after the site has undergone functional changes.
Redirect the first time a user logs in
Sometimes it is helpful to direct first-time users to a special orientation or training page. For this method, your user profile must contain a Yes/No field (in our example Finished_Training). Using a Single Record Update Form with this Yes/No type field will allow you to display important information to new users and allow them to skip this screen when they become more comfortable.
if("[@authfield:Finished_Training]" == "No"){
window.location = "http://www.mysite.com/training.html";
}
else{
window.location = "http://www.mysite.com/menu.html";
}
</script>
In this example new users are directed to “training.html” where they are presented with training information and checkbox saying “Don’t show this screen again”. This training page will appear every time they login until they click the check box.
Please note: This article uses external HTML, JavaScript, or third-party solutions to add functionality outside of Caspio Bridge's standard feature set. These solutions are provided "as is" without warranty, support or guarantee. The code within this article is provided as a sample to assist you in the customization of your web applications. You may need a basic understanding of HTML and JavaScript to implement successfully.

Please note: This article uses external HTML, JavaScript, or third-party solutions to add functionality outside of Caspio Bridge's standard feature set. These solutions are provided "as is" without warranty, support or guarantee. The code within this article is provided as a sample to assist you in the customization of your web applications. You may need a basic understanding of HTML and JavaScript to implement successfully.
Can the script for the Redirect be pasted into the same html datapage that has the Stand Alone Login script?
I found out the answer. YES. The script for the Redirect can be pasted into the same html datapage (caspio's) that has the script for the Stand Alone Login. Paste it under the script for the Stand Alone Login. You do not need to create a separate html datapage for the Redirect.
However, you must deploy the html datapage (with the Stand Along Login script and the Redirect Script) on a webpage that is different than the ones you have as Redirect options.
I have a user table (named USER) with an Admin yes/no and Agent yes/no
I have two views setup. One filters for Admin and the other filters for Agent
When I attempt to setup Web user authentication using either the USER table, Admin, or Agent views I don't see the "USERS_Admin" or "USERS_Agent" fields from the USER table.
Question: What is the @authfield parameter?
How would I use the if("[@authfield:Position]" == "Manager"
with a user table that uses yes/no (field options are labeled Admin and Agent)
I'm probably in over my head here, so let me know if I'm way off track.
As I understand you are trying to redirect users to different pages based on a Yes/No field value. If that is the case you can use it in this format:
if ("[@authfield:FieldName]" == "Yes") // If it is checked in the table
{
window.location = "URL";
}
else if ("[@authfield: FieldName]" == "No") // If it is not checked in the table
{
window.location = "URL";
}
You can use [@authfield:FieldName] to receive authentication table fields in your DataPages. If you have a view as the authentication source, please make sure you are replacing the complete name with FieldName. To double check please open the view and get the name (It should be something like "TableName_FieldName"). You can read more about parameters at http://wp.me/P10x67-38.
As it describes at the bottom of the tutorial, this article uses external JavaScript solutions to add functionality outside of Caspio Bridge's standard feature set. These solutions are provided "as is" without warranty, support or guarantee. The code within this article is provided as a sample to assist you in the customization of your web applications. You may need a basic understanding of HTML and JavaScript to implement successfully.
Hope that helps. We've also responded to you via a support ticket.
Sincerely,
Caspio Support