Click to See Complete Forum and Search --> : random session


twixy2k
02-10-2003, 01:33 PM
hi, I 'm using this to produce a random number in lowercase, 5 charc long. I've tried some hand editing to one thats in dreamweaver but anit working proper.
Thanks
<%
var firstLower,passwordLength,


firstLower = true
latterLower = true
passwordLength = 5

function getRandomNum(lbound, ubound) {
return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
}
function getRandomChar(lower){
var lowerChars = "abcdefghijklmnopqrstuvwxyz";

if (lower == true)
charSet += lowerChars;

return charSet.charAt(getRandomNum(0, charSet.length));
}
function getPassword(length, firstLower, latterLower) {
var rc = "";
if (length > 0)
rc = rc + getRandomChar(firstLower);
for (var idx = 1; idx < length; ++idx) {
rc = rc + getRandomChar(latterLower);
}
return rc;
}

strUltraPass = getPassword(passwordLength, firstLower, latterLower)
%>
<%Session("svuser") = strUltraPass%>

Ribeyed
02-10-2003, 04:42 PM
hi,
what exactly is it thats not working? Is all the code falling over or is it just not doing what you want it to do?

This code seems strange to me. It looks like some ASP and some JavaScript thrown in for good luck.

twixy2k
02-11-2003, 05:48 AM
Hi,
The code is ment to write a session to the server everytime it's read. Its ment to be a 5 letter lowercase word. It's from a built in extension in dreamweaver extensions. Is it possible to get a shorter neater better more accurate script?
Thankyou

Ribeyed
02-11-2003, 06:24 AM
hi,
as i said in my above post the code you have looks to me like some ASP and some JavaScipt mixed in wrongly.
Yes there would be a way to do what you want it do but are ytou wanting ASP or JavaScipt?
It looks to me like you are a beginner and working with sessions is not that easy to understand. Maybe you need learn to crawl before you can run. Try some tutorials on correct syntax for the code you want to write.
You are also not looking for random session variables, but for how to write a random string to a session variable.