Bonjour,
premièrement je confirme que sous chrome cela marche à 100 %. cependant avec ie et safari mes sessions ne fonctionnent que 3 fois sur 4.
Je présume que mon code est bon sinon il planterait a chaque fois.
en faisant du débug avec un fichier log j'ai constaté ceci.
structure du fichier :
index.php => ($_POST[login] Veriflogin.php $_SESSION['login']=$_POST['login']=> indexgranted.php.
dans mes logs je vois que que ma variable $_SESSION['login'] est bien associée à mon login. puis je passe dans un header (location : indexgrated.PHP) et arrivé dans on fichier indexgranted ma variable $_session['login'] est vide.
Pourtant ce code fonctionne toujours avec chrome et 3 fois sur 4 avec safari !
quelqu'un aurait une idée ?
je vous copie mes code de vériflogin et index granted
Merci, bien à vous
veriflogin.php
et indexgranted.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <title>Vérif_users</title> <style type="text/css"> <!-- @import url("style.css"); --> </style> </head> <body> <?php session_start(); $flag=0; echo "<br> Bonjour, ".$_POST['nom']; $fichier="./log/connection.txt"; $handle = fopen($fichier,'a'); if ($handle) { $today = getdate(); $buf = $today[year]."-".$today[mon]."-".$today[mday]." ".$today[hours].":".$today[minutes].":".$today[seconds]; fprintf($handle,$buf); } fclose($handle); if (isset($_POST['nom']) && isset($_POST['pass'])) { $fichier="./log/connection.txt"; $handle = fopen($fichier,'a'); if ($handle) { $today = getdate(); $buf = " Isset : ".$_POST['nom']; fprintf($handle,$buf); } fclose($handle); $handle = fopen('login.txt','r'); if ($handle) { while (!feof($handle)) { $buffer = fgets($handle); if ($buffer[0]!="#") { if (strstr ($buffer,';')) { $buff = explode (";",$buffer); } if (($_POST['nom'] == $buff[0]) && ($_POST['pass'] == $buff[1])) { $flag=1; $droits=$buff[2]; } } } } fclose($handle); //echo $droits[11]; if ($flag=="1") { if ($droits[11]=="1") { //session_start (); // header('P3P: CP="CAO PSA OUR"'); $_SESSION['login'] = $_POST['nom']; $_SESSION['pwd'] = $_POST['pass']; $_SESSION['droits'] = $droits; echo "Accès Granted "; echo $_SESSION['login']; echo $_SESSION['pwd']; echo $_SESSION['droits']; $fichier="./log/connection.txt"; $handle = fopen($fichier,'a'); if ($handle) { $buf = " Flag1 SESSION : ".$_SESSION['login']; fprintf($handle,$buf); } fclose($handle); header ('location: index_granted.php'); } else Echo "Vous n'avez pas le droit d'accès à ce site"; } else { echo "Nom ou mot de passe incorrect."; } } else { echo "<br> Probleme de POST parametres"; } ?> </body> </html>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <title>Pompier de Philippeville</title> <style type="text/css"> <!-- @import url("style_index.css"); --> </style> </head> <body> <div id="conteneur"> <h1 id="header"> <div class="box_header"> <?php session_start(); header('P3P: CP="CAO PSA OUR"'); if(isset($_SESSION['login'])) { echo "Vous êtes connecté en tant que : <br>"; echo $_SESSION['login']; $fichier="./log/connection.txt"; $handle = fopen($fichier,'a'); if ($handle) { $buf = " IndexGranted_True " .$_SESSION['login']."\n"; fprintf($handle,$buf); } fclose($handle); $droits = $_SESSION['droits']; if ($droits[11] != "1") header ('location: refuse.php'); echo '<form action="logout.php" method="post"> <input type="submit" value="Déconnexion"> </form>'; } else { $fichier="./log/connection.txt"; $handle = fopen($fichier,'a'); if ($handle) { $buf = " IndexGranted_false " .$_SESSION['login']." ".$_SESSION['pwd']." ".$_SESSION['droits']."\n"; fprintf($handle,$buf); } fclose($handle); header ('location: index.php'); } ?> </div> <!--box_header--> </a></h1>
Partager