PDA

View Full Version : Log-in script being bad again


Bobo
12-29-2004, 06:05 PM
For a site of mine, I'm using a log-in script. It uses cookies and location.search to remember the user's name. The cookies, however, are not saving at all.

I know my browser is allowing all cookies because this site is using them successfully after I cleared them all.

The script is as follows:

<script language="VBScript">
Dim dataa
Sub Egg()
dataa=inputBox("hi","hi")
ret(dataa)
End Sub




</script>



<script language=Javascript>
var Username='',temp='',other='',Dat=new Date(),reset=false;
function Init()
{
if (document.cookie)
{
temp=document.cookie.split('=');
Username=unescape(temp[1]);
reset=false;
ret(Username);
}
else
{
reset=true;
Egg()
}
}
function ret(name)
{
Username=name;
// alert(Username)
Dat.setTime(Dat.getTime()+(7*24*60*60*1000));
if (reset&&Username!=undefined&&Username!='')
{
document.coookie="user="+escape(Username)+";expires="+Dat.toGMTString()+";";
}
else if (Username==undefined||Username=='')
{
Username='guest'
}
// alert(Username+reset+temp[0]+Dat+'\n\b'+document.cookie)
parent.location.search=Username

}







window.onload=Init
</script>



Can anyone find the problem? I've trying to fiqure it out for the past hour! :confused:

Brandoe85
12-29-2004, 06:44 PM
I didn't read your script in dept but noticed you are calling your vbscript sub within your javascript, obviously it's not going to know what that is...

Bobo
12-29-2004, 06:56 PM
Actually, the JS is successfully calling the VB and vice versa. The entire script runs throught successfully, but the part with the cookie isn't working.

Brandoe85
12-29-2004, 07:02 PM
Doesn't work for me in IE 6, or FF 1.0, in IE it prompts me forever with hi, and in FF it wont even run, returning the error Egg() is not defined.

Bobo
12-31-2004, 02:59 AM
Let's just worry about IE. I can put script in to detect browser and what-not. It's constantly prompting you because the last line of code (parnet.location.search=Userneamt) causes the page to reload and without the cookies saving, hence it has to ask you your name everytime in loads and sets the window.loc.search again, creating a loop. So, without the last line of code, all is well except the cookie saving part. Is something wrong w/ my syntax? Should the code arrangement be adjusted? I've used VB/JS mixes just like this one sucessfully before, so that can't be it. I've gotten the same cookie problem using no VB and the JS prompt, so that's not affecting it.

Are there any other possibilities and/or problems?? :confused:

Brandoe85
12-31-2004, 06:56 AM
Since this post I have done some searching on vbscript and javascript, and have read that they can work together(though i've never tried it since i've never done vbscript,besides asp, ill assume they can), I just never use IE so I didn't know. So I didn't mean for my first post to sound offending, anways, I dont have time right now to really look at your script, but I do have a cookie login script I have made before if your interested...otherwise maybe i'll check yours out a little later, maybe in the next day or two...

Bobo
01-01-2005, 10:09 PM
Thanks, I'd like to see that script. BTW, I didn't mean to imply that I took any offense from your post. I appreciate anything I get, I was just saying that that I already tested what you told me in your first post. :)