PDA

View Full Version : setting cookies after a login...with local files


johnnyb
04-20-2003, 09:30 AM
Hello,

Here's a quandry for you all.... I'll try to be clear explaining what I want, but it may be hard.

I am making some HTML documents which will be viewed off of a CD - so any scripting on them has to be done with JS..

However, these files are pulling some info from a http server, which is fine, except I have to have the people submit a username & password to the server, and then have a record on their local computer, (ie a cookie), of if it was accepted or not.

The best way I can figure to do it is to include the username & password in the querystring of a URL that returns an external JS file to be executed in the browser, however, how do I get the username & pass into the querystring?

Or, does anyone else know of another way to solve the problem?

smeagol
04-21-2003, 12:43 PM
If it were me, I would program the page that the form submits to so that if everything is accepted, write a cookie to the client computer saying "accepted". If it's not accepted, the page would write a cookie saying "denied".

What server-side language are you using for accepting the data from the form?

johnnyb
04-21-2003, 06:50 PM
Hello,

I am using ASP as my server-side language for this project.

I was under the impression that I wouldn't be able to do as you say, since the script writing the cookie would be at one domain, (ie www.somedomain.com), and the pages that would have to access it would be at another, (local files on the client's computer)... Is it actually possible to read cookies accross domains this way?

JB

smeagol
04-21-2003, 11:16 PM
Ooooohhhh.........I didn't realize that. Hmmmm......I'll have to think about that one.

johnnyb
04-21-2003, 11:25 PM
I could accomplish what I want to do if I can somehow change the target, (ie "action"), of the log-in form based on the form input... Do you know how to do that?

JB

smeagol
04-21-2003, 11:36 PM
Do you mean change the target (right before it's submitted) based on the input of the form? That should be possible through JavaScript.

In your form tag, put this:

onsubmit="dictateFormAction(this)"

Then put this function in the head of your page:

<script language="JavaScript">

function dictateFormAction(objForm){
objForm.action = 'whateverpage.asp';
}
</script>

Then put your IF statement in that function to dictate the criteria the form must meet for whichever page. Example:

if(objForm.txtFirstName == '')
objForm.action = 'firstpage.asp';
else
objForm.action = 'secondpage.asp';

If you still have trouble with that, let me know. I'll do my best to help you out.