Ïðè àâòîðèçàöèè ñîõðàíÿþ id ïîëüçîâàòåëÿ â my
cookieÂñå íîðìàëüíî àâòîðèçèðóåòñÿ, âûâîäèò âñå ÷òî íóæíî íà ãëàâíîé ñòðàíèöå.
Íî êîãäà íà÷èíàþ ïåðåõîäèòü ïî äðóãèì ñòðàíèöàì, ïîêàçûâàåòñÿ ÷òî my
cookie ïóñò..Õîòÿ è â äðóãèõ ñòðàíèöàõ ïîäêëþ÷åíà ôóíêöèÿ âûâîäà.
function show_mylogin(){
$my
cookie=$_COOKIE['my
cookie'];
if ($my
cookie!=""){....êàêîå òî äåéñòâèå...}
...
}
 ÷åì ìîæåò áûòü?
Âðåìÿ ðàáîòû
êóêè 1 ÷àñ íî îíè èç÷åçàþò ñðàçó ïðè ïåðåõîäå
Ñïóñòÿ 21 ìèíóòà, 52 ñåêóíäû (1.04.2009 - 16:41) Sylex íàïèñàë(à):
NegreMäëÿ óñòàíîâêè êóê þçàåì:
http://ru.php.net/setcookieâ êîòîðîì ìîæíî óêàçàòü âðåìÿ è äð. ïàðàìåòðû
Ñïóñòÿ 4 äíÿ, 56 ìèíóò, 27 ñåêóíä (5.04.2009 - 17:38) PandoraBox2007 íàïèñàë(à):
admin.php
PHP |
<?php
$admin_login = "testadmin"; $admin_pass = "123";
$login = $_POST['login']; $password = $_POST['password'];
if($_GET['logout'] == 'ok') { setcookie('login'); setcookie('password'); header('Location: http://site/admin.php?done'); }
if ($_POST['btn_login']) if ($login == $admin_login && $password == $admin_pass) { setcookie('login', $login, time()+3600); setcookie('password', $password, time()+3600); header('Location: http://site/admin.php'); } else { $error_log .= '<font color="red" style="font-weight:bold;">Ëîãèí èëè ïàðîëü íå ñîâïàäàåò!</font><br>'; }
if (isset($_REQUEST['done'])) {
$error_log .= '<font color="#009900" style="font-weight:bold;">Cookie î÷èùåíû!</font><br>'; }
?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251" /> <title>Admin</title> <style> .topmenu { background:#E7F1F9 none repeat scroll 0 0; border:1px solid #4C96D4; margin:0 1px; padding:0 8px; } a { color:#1162B3; text-decoration:none; } a:hover { text-decoration:underline; } </style> </head>
<body> <table width="100%" height="100%" border="0" align="center"> <tr> <td colspan="5"><?php if ($_COOKIE['login'] == $admin_login && $_COOKIE['password'] == $admin_pass) { $login = $_COOKIE['login']; echo <<<HTML <div class="topmenu"> <table width="100%" cellspacing="0" cellpadding="0"> <tbody><tr> <td width="50%">Äîáðî ïîæàëîâàòü: <b class="med">$login</b> <a onclick="return confirm('Âû óâåðåíû, ÷òî õîòèòå âûéòè?');" href="admin.php?logout=ok">[ Âûõîä ]</a></td> </tr></tbody> </table> </div> HTML; } else { echo <<<HTML <form method="POST"> <table width="15%" border="0" align="center" style="border:1px solid #000000;"> <tr> <td width="100"><img src="img/usr.png" width="16" height="16" border="0" /> <b>Ëîãèí:</b></td> <td><input name="login" type="text" value="" maxlength="16" /></td> </tr> <tr> <td><img src="img/key.png" width="16" height="16" border="0" maxlength="32" /> <b>Ïàðîëü:</b></td> <td><input name="password" type="password" value="" /></td> </tr> <tr> <td colspan="2" align="center">$error_log<input style="width:75px;" name="btn_login" type="submit" value="Âõîä"></td> </tr> </table> </form> HTML; }?></td> </tr> </tab |
_____________
Ìîÿ ìàìà çàïðåùàëà ìíå â äåòñòâå ðèñîâàòü â Paint, ññûëàÿñü íà òî, "÷òîá â êîìïüþòåðå êðàñêà íå êîí÷àëàñü" :)