����� 2
�� 11: ����� ������ �� ���� cookies ������.
��� ������ ����� ���� ����� ���� �� �- cookie ���. ��� ����� ����� ���, ��� �"� ����� ����� cookies.
����� ���� cookies ��� ���� �����. ����� ���� cookie �� ��. ������ �������, ����� �- cookie ���� ���: my_happy_cookie, ������ ���� ���:
var the_cookie = "my_happy_cookie=happiness_and_joy";
document.cookie = the_cookie;
�� ��� ����� ���� cookies, ���� ����� �� ���� ��� cookie. �� ��� ���� ������ ����, ����� document.cookie ���� ����� �� cookies ���� ��. �� ��� ���� ��� ��:
var the_cookie = "my_happy_cookie=happiness_and_joy";
document.cookie = the_cookie;
var another_cookie = "my_other_cookie=more_joy_more_happiness";
document.cookie = another_cookie;
����� �� �� ����� ���� �������. �� ��� ����, �� ���� ���� ���� ����� �� ���.
��� ���� ���� ���� �� ���� ���� ������, ������� ���� �� my_happy_cookie. �� ���� �- document.cookie ��� ����:
my_happy_cookie=happiness_and_joy;
my_other_cookie=more_joy_more_happiness;
�� ��� �� ����� �� ���� ��� �- cookie.
�� ���� ����, ���� ����� cookie ������� ����� ��� ���� ������. ��� ��� ������ ����� cookie �������. ���� ���� ������� �- cookies �� webmonkey.
function WM_readCookie(name)
{
// if there's no cookie, return false else get the value and return it
if(document.cookie == '')
return false;
else
return
unescape(WM_getCookieValue(name));
}
function WM_getCookieValue(name)
{
// Declare variables.
var firstChar, lastChar;
// Get the entire cookie string.
// (This may have other name=value pairs in it.)
var theBigCookie = document.cookie;
// Grab just this cookie from theBigCookie string.
// Find the start of 'name'.
firstChar = theBigCookie.indexOf(name);
// If you found it,
if(firstChar != -1)
{
// skip 'name' and '='.
firstChar += name.length + 1;
// Find the end of the value string (i.e. the next ';').
lastChar = theBigCookie.indexOf(';', firstChar);
if(lastChar == -1) lastChar = theBigCookie.length;
// Return the value.
return theBigCookie.substring(firstChar, lastChar);
} else {
// If there was no cookie, return false.
return false;
}
}
������ ����� ��� ����� / ����� ����, ��� ��� �� ������� ���� ���� (�� �����, ��� ���� �� �� ��� ���� �� ��� ����� �� ����).
���� ������ ���� ������ �� �� ����, ��� ����� �� ���� ����� ����� ������ cookies �������, ������ ����� ������� ����� ������ ����� �������� ���� ���� ���� ������� cookies.
���� ������ ���
��� ��� «--
|