asp代码转化为javascript脚本问题

来源:百度知道 编辑:UC知道 时间:2024/06/19 09:40:46
<% if Session("Userid")="" or Session("Password")="" then %>登陆<%else%>您已经登陆<%end if%>
如果这段代码用javascript应该怎么写呢?
或者用javascript实现相同的功能

javascript 不能操作服务器端的Session,Cookie倒可以。

cookie可以伪造,还是用动态语言比较安全!!!

<script type="text/javascript">

if(getCookie("Userid")=="" || getCookie("Password")==""){
document.write("登录");
}else{
document.write("您已经登陆");
}

function getCookie(arg_CookieName){fromN=document.cookie.indexOf(arg_CookieName+"=")+0;if((fromN)!=-1){ fromN+=arg_CookieName.length+1; toN=document.cookie.indexOf(";",fromN)+0; if(toN==-1){ toN=document.cookie.length} return unescape(decodeURI(document.cookie.substring(fromN,toN))) } return "" }

</script>