استفاده از کوکي در باز کردن يک فايل php

hamid2007id

تازه وارد
سلام

فايل code.js يه کوکي ميسازه :



function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
x=ARRcookies.substr(0,ARRcookies.indexOf("="));
y=ARRcookies.substr(ARRcookies.indexOf("=")+1);
x=x.replace(/^\s+|\s+$/g,"");
if (x==c_name)
{
return unescape(y);
}
}
}

function setCookie(c_name,value)
{
var exdays= 0;
var exdate=new Date();
exdate.setHours(exdate.getHours() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}

function checkCookie()
{
var username1=getCookie("id");
var usernam = "sendshod";
if(username1==null){
window.open('#','_parent','toolbar=0,location=1,directories=0,status=0,menubar=0,scrollbars=0,resizable=0');
window.focus();
}
if(username1=="" | username1==null){
if(window.open('http://mysite.ir/view.php?id='id','_blank','toolbar=0,scrollbars=0,location=1,statusbar=0,menubar=0,resizable=0,width=0,height=0,top=0,left=0')){
window.focus();
setCookie("id",usernam);
}
}


کد:


آيا کوکي بالا درسته ؟ و اطلاعات id رو به view.php مرسونه ؟

اين هم کدفرضي



<!--اين کد را در سايتتان قرار دهيد -->
<script type="text/javascript">var id = '666666';</script>
<script type="text/javascript" src="http://mysite.ir/code.js"></script>
<!--اين کد را در سايتتان قرار دهيد -->
کد:
 
آخرین ویرایش توسط مدیر:

erfan

طراح وب
پرسنل مدیریت
انتقال یافت انجمن پرسش و پاسخ!

لطفا دقت کنید...

 
بالا