Jestem ciekaw, jak rozwiązaliście problem autologowania w Waszych aplikacjach. U mnie wygląda to tak, że jeżeli użytkownik nie jest zalogowany, sprawdzane jest jego ciasteczko w którym zapisane są dane:
Kod
id_usera,haslo_md5
nie jestem pewien bezpieczeństwa swojego sposobu. Dodam jeszcze skromny kod:
<?php
class autologin_Vapplet extends Vapplet
{
public function index_Action()
{
throw new VappletException('Hmmm !');
}
public function Autologin_Action()
{
$oUser = new Vuser();
if(!$oUser->isAuth())
{
$oInput = new Vinput();
$aCookieAuth = explode(',', $oInput->cookie('auth'));
$sAuthId = $aCookieAuth[1];
$sAuthPs = $aCookieAuth[0];
if($sAuthId && $sAuthPs)
{
$oModel = $this->setModel('user');
$aUserData = $oModel->getUser($sAuthId);
if($aUserData['user_pass'] == $sAuthPs)
{
$oUser->setAuth(true);
$oUser->name = $aUserData['user_name'];
$oUser->id = $aUserData['user_id'];
if($aUserData['user_admin'] == 'y')
$oUser->setGroup('administrator');
}
}
}
}
public function SetCookie_Action()
{
setCookie('auth', $this->pass . ',' . $this->user, (time() + (60 * 60 * 24 * 14)), '/'); }
public function HasCookie_Action()
{
$oInput = new Vinput();
return $oInput->cookie('auth');
}
public function DeleteCookie_Action()
{
}
}
?>
Ten post edytował Athlan 21.03.2007, 11:15:42