Yes et pourtant comme je t'ai dis je l'ai geré a la maniere de grafikart
voici le zonecontroller
<?php
class ZonepersoController extends Controller{
function index(){
if(!$this->Session->isLogged()){
$this->redirect('zoneperso/login');
}else{
$this->loadmodel('fiche_joueur');
$this->loadmodel('fiche_membre');
$this->loadmodel('fiche_sociale');
$this->loadmodel('messagerie');
$identifiant_id = $this->Session->read('User')->id_identifiant; //Corespond a l'identifiant du gars connecté
$fiche_joueur = $this->fiche_joueur->findFirst(array('conditions'=>array('identifiant_id'=>$identifiant_id)));
if(empty($fiche_joueur)){
$fiche_joueur = 'Nous n\'avons trouvé aucune fiche vous concernant.';
}
$fiche_membre = $this->fiche_membre->findFirst(array('conditions'=>array('identifiant_id'=>$identifiant_id)));
if(empty($fiche_membre)){
$fiche_membre = 'Nous n\'avons trouvé aucune fiche vous concernant.';
}
$fiche_sociale = $this->fiche_sociale->findFirst(array('conditions'=>array('identifiant_id'=>$identifiant_id)));
if(empty($fiche_sociale)){
$fiche_sociale = 'Nous n\'avons trouvé aucune fiche vous concernant.';
}
$messagerie = $this->messagerie->find(array( 'conditions' =>array('messagerie_auteur'=>$identifiant_id,'messagerie_destinataire'=>$identifiant_id),
'et' => 'or' ));
$this->loadmodel('messagerie_message');
$tab_message =array();
foreach($messagerie as $k=>$v){
$message = $this->messagerie_message->findFirst(array( 'conditions'=>array('message_messagerie'=>$v->messagerie_id),
'special' =>'SELECT message_content,message_date,
vu_auteur,vu_destinataire,
fm_avatar,
identifiant
FROM messagerie_message
LEFT JOIN message_vu ON messagerie_message.message_messagerie=message_vu.vu_messagerie
LEFT JOIN fiche_membre ON messagerie_message.message_auteur=fiche_membre.fm_id
LEFT JOIN identifiant ON fiche_membre.identifiant_id=identifiant.id_identifiant',
'afterwhere' => 'ORDER BY message_date DESC'));
$tab_message$v->messagerie_id] =array( 'messagerie_id' =>$v->messagerie_id,
'messagerie_auteur' =>$v->messagerie_auteur,
'messagerie_destinataire' =>$v->messagerie_destinataire,
'message' =>$message
);
}
$this->set("ficheJoueur",$fiche_joueur);
$this->set("ficheSociale",$fiche_sociale);
$this->set("ficheMembre",$fiche_membre);
$this->set("Messagerie",$tab_message);
$this->set("MyId",$identifiant_id);
}
$this->set('isconnect',$this->Session->isLogged());
}
function formConnect(){
$class = "mustfit backtransparent padding10px colorf7f7f7 bordernone width70per100";
$Form = $this->Form->input('identifiant','Login',array('class' =>$class,
'placeholder' =>'Entrer votre identifiant')).
$this->Form->input('password','Mot de passe',array( 'type' =>'password',
'class' =>$class)).
$this->Form->input('logoncookie','Se souvenir de moi',array( 'type' =>'checkbox'));
return $Form;
}
function formInscription(){
$class = "mustfit backtransparent padding10px colorf7f7f7 bordernone width70per100";
$Form = $this->Form->input('identifiant','Login',array('class' =>$class,
'placeholder' =>'Entrer votre identifiant'
)).
$this->Form->input('password','Mot de passe',array( 'type' =>'password',
'class' =>$class
)).
$this->Form->input('confirmation','Confirmation',array( 'type' =>'password',
'class' =>$class
)).
$this->Form->input('email','Email',array( 'type' => 'email',
'class' =>$class,
'placeholder' =>'Votre email'
));
return $Form;
}
function login(){
if($this->request->data){
$data = $this->request->data;
if(!empty($this->request->data->identifiant) AND !empty($this->request->data->password)){
$data->password = sha1($data->password);
$this->loadmodel('identifiant');
$user = $this->identifiant->findFirst(array('conditions'=>array('identifiant'=>$data->identifiant,'password'=>$data->password)));
if(!empty($user)){
/*IL a rentré des bonnes infos*/
$this->Session->setFlash("Vous etes bien connecté");
$this->Session->write('User',$user);
}else{
$this->Session->setFlash("Votre identifiant et mot de passe n'ont pas étés trouvés dans notre base de donnée","error");
}
}else{
$this->Session->setFlash("Vous devez remplir votre identifiant et mot de passe","error");
}
$this->request->data->password = "";
}
$this->set('FormConnect' , $this->formConnect());
if($this->Session->isLogged()){
$this->redirect('zoneperso');
}
}
function logout(){
unset($_SESSION'User']);
$this->redirect('home');
}
function inscription(){
/*
** On regarde d'abord si il est pas deja connecte
*/
if($this->Session->isLogged()){
$this->redirect('zoneperso');
}else{
if($this->request->data){
$error = false;
$message ='';
$data = $this->request->data;
/ **********
** Check l'identifiant
********** /
if(empty($data->identifiant)){
$message.='Votre identifiant doit être remplis.<br />';
$error = true;
}elseif(strlen($data->identifiant)<5 OR strlen($data->identifiant)>15){
$message.='Votre identifiant doit contenir entre 5 et 15 caractères strictement alphanumerique.<br />';
$error = true;
}elseif(preg_match('#^a-zA-Z0-9._]#' ,$data->identifiant)){
$message.='Votre identifiant ne doit contenir que des caractères alphanumerique(aucun caractères speciaux).<br />';
$error = true;
}
/ **********
** Check le password et sa confirmation
*********** /
if(empty($data->password)){
$message.='Votre mot de passe doit être remplis.<br />';
$error = true;
}else{
if(strlen($data->password)<8 OR strlen($data->password)>15){
$message.='Votre mot de passe doit contenir entre 8 et 15 caractères strictement alphanumerique.<br />';
$error = true;
}elseif($data->password != $data->confirmation){
$message.='Vos mot de passes sont différents.<br />';
$error = true;
}
}
/ *********
** Check l email
********** /
if(empty($data->email)){
$message.='Votre email doit être remplis.<br />';
$error = true;
}elseif(!filter_var($data->email, FILTER_VALIDATE_EMAIL)){
$message.='Votre email n\'est pas au bon format.<br />';
$error = true;
}
/ *********
** On traite le resultat du traitement
** Si $error = true => Alors on setflash un message d'error
** Si $error = false => Alors on setFlash un message success et on insert
********* /
if($error){
$this->Session->setFlash($message,'error');
}else{
/ *******
** On verifie d'abord qu'il ne soit pas dejà enregistré
******* /
$this->loadmodel('identifiant');
$user = $this->identifiant->findFirst(array('conditions'=>array('identifiant'=>$data->identifiant)));
if(empty($user)){
$this->loadmodel('fiche_joueur');
$this->loadmodel('fiche_membre');
$this->loadmodel('fiche_sociale');
$data->password = sha1($data->password);
$data->identifiant = strtolower($data->identifiant);
$insert_membre = $this->identifiant->insert(array(
'champs' =>'identifiant,password,email',
'params_insert' =>':pseudo, :mdp, :email',
'values' =>array('pseudo' => array($data->identifiant,'PDO::PARAM_STR'),
'mdp' => array($data->password,'PDO::PARAM_STR'),
'email' => array($data->email,'PDO::PARAM_STR')
),
'retour' =>'lastinsertid'
));
$fiche_joueur = $this->fiche_joueur->insert(array(
'champs'=>'identifiant_id','params_insert'=>':id',
'values'=>array('id' => array($insert_membre,'PDO::PARAM_INT'))
));
$fiche_membre = $this->fiche_membre->insert(array(
'champs'=>'identifiant_id','params_insert'=>':id',
'values'=>array('id' => array($insert_membre,'PDO::PARAM_INT'))
));
$fiche_sociale = $this->fiche_sociale->insert(array(
'champs'=>'identifiant_id','params_insert'=>':id',
'values'=>array('id' => array($insert_membre,'PDO::PARAM_INT'))
));
/ *********
** On crée la variable de session USER
** On crée le message de retour
** On redirige sur l'accueil de sa nouvelle zone
********* /
$user = $this->identifiant->findFirst(array('conditions'=>array('identifiant'=>$data->identifiant,'password'=>$data->password)));
$this->Session->write('User',$user);
$this->Session->SetFlash("Vous êtes enregistré");
$this->redirect('zoneperso');
}else{
$this->Session->setFlash("L'identifiant est déjà dans la base de donnée",'error');
}
}
$this->request->data->password = "";
$this->request->data->confirmation = "";
}
$this->set('FormInsc',$this->formInscription());
}
}
function modification(){
if($this->Session->isLogged() && $this->request->data){
$table = $this->request->data->table;
$champ = $this->request->data->champ;
$value = $this->request->data->value;
$this->loadmodel($table);
$this->$table->update(array(
'condition' => array('identifiant_id' => $this->Session->read('User')->id_identifiant),
'champs_update' => $champ.'=:champ',
'values' => array('champ'=> array( $value,'PDO::PARAM_STR')
)
));
}
$this->redirect('zoneperso');
}
function lecturemessagerie($id=NULL){
if(isset($id) AND !empty($id) AND is_numeric($id)){
$this->loadmodel('messagerie');
$messagerie = $this->messagerie->find(array('conditions'=>array('messagerie_id'=>$id)));
$arrayUser = $this->Session->read('User');
foreach($messagerie as $k){
$this->loadmodel('messagerie_message');
if($k->messagerie_auteur == $arrayUser->id_identifiant || $k->messagerie_destinataire == $arrayUser->id_identifiant ){
$message = $this->messagerie_message->find(array( 'conditions'=>array('message_messagerie'=>$k->messagerie_id),
'special' =>'SELECT message_id,message_content,message_date,
fm_avatar,
identifiant
FROM messagerie_message
LEFT JOIN fiche_membre ON messagerie_message.message_auteur=fiche_membre.fm_id
LEFT JOIN identifiant ON fiche_membre.identifiant_id=identifiant.id_identifiant',
'afterwhere' => 'ORDER BY message_date DESC'));
foreach($message as $v){
$tab_message$v->message_id] = array( 'message_id' => $v->message_id,
'message_auteur' => $v->identifiant,
'message_avatar' => $v->fm_avatar,
'message_content' => $v->message_content,
'message_date' => $v->message_date
);
}
$this->set('good',true);
$this->set('listeMessage',$tab_message);
}else{
$this->set('good',false);
$this->Session->setFlash("Ce message ne vous est pas destiné.","error");
}
}
}else{
$this->Session->setFlash("Une erreur s'est produite.","error");
}
}
}
?>
Ma page login.php
<div class="intitulesection"><h5>Your private home</h5></div>
<?php
echo '<div class="width50per100 alignauto margintop10px">'.$this->Session->Flash().'</div>';
?>
<div id="zoneconnection" class="alignauto margintop40px width50per100 vatop">
<div id="zonecontact" class="width95per100 backtrans91141a alignauto bordertransgrey">
<div class="padding10px fontsize1 tacenter back000">Connection</div>
<form action="<?php echo Router::url('zoneperso/login'); ?>" method="post" autocomplete="off">
<?php echo $FormConnect ;?>
<div class="zonetransparente tacenter marginbottom10px">
<input type="submit" value="me connecter" class="back000 fontsize1 padding10px colorf7f7f7 bordernone width70per100" />
</div>
</form><a href="<?php echo Router::url('zoneperso/inscription'); ?>">Pas encore inscrit?</a>
</div>
</div>
J'ai remis le flash pour te dire que t'es bien connecté ainsi que le debug qui te montre que la session est bien présente
Puis recharge la page tous en effacant les données qdu formulaire et tu remarque que la session n'existe deja plus :( je sais pas d'ou viens mais quelques parts je dois surement lui dire que a chaque recharge il m'efface ou redemarre une nouvelle session??
Mais je sais plus où c'est ?