session
want mijn probleem is het volgende.
Als ik inlog dan geeft i iederekeer een nieuw sessie id maar als ik dan op een link klik (in mijn geval games) en daar dan de sessie gegevens weer ophaal dan krijg ik weer een nieuw id dus ik ben mijn sessie gegevens van mijn vorige sessie kwijt. maar log ik nu uit dan hou ik steeds mijn sessie id die ik bij de pagina games heb gekregen en die kan ik ook niet meer kwijt raken.
De source codes
///////////////////////// login pagina
Code (php)
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
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
<?php
if ($login == "ja") {
include("dbconnect.php");
$query = mysql_query("SELECT * FROM leden WHERE username = '$username' AND password = '$password'");
$tabel = mysql_fetch_array($query);
if ($tabel[username] == "" && $tabel[password] == "") {
echo '
U hebt geen of verkeerde gegevens ingevult.<BR>
Klik op vorige in uw browser en vul nu wel iets in.
';
}
else {
session_start();
header("Cache-control: private");
echo "Username: $tabel[username]<BR>";
echo "Id: $tabel[id]<BR>";
echo "Your session ID is <strong>". session_id() ."</strong><BR>";
echo "Saldo: $tabel[saldo]<BR><BR>";
echo '<a target="_top" href="index.php?login="><B>Uitloggen<B></a><BR>';
echo '<a target="iframe" href="games.php">Games</a><BR>';
echo '<a target="iframe" href="nbs.html">Bestellen</a><BR>';
echo '<BR><BR><BR><BR><BR><BR>';
$_SESSION['username'] = $tabel[username];
$_SESSION['password'] = $tabel[password];
}
}
else {
session_start();
header("Cache-control: private");
$_SESSION['username'] = FALSE;
$_SESSION['password'] = FALSE;
session_destroy();
if($_SESSION['username']){
echo "The session is still active";
} else {
echo "$_SESSION[password] Ok, the session is no longer active! <br />";
}
echo '<B>U bent niet ingelogd</B>';
echo '
<FORM NAME="formulier" ACTION="index.php" METHOD="post">
Username:<INPUT TYPE="text" NAME="username"><BR>
Wachtwoord:<INPUT TYPE="password" NAME="password"><BR>
<input type="hidden" name="login" value="ja">
<INPUT TYPE="Submit" NAME="Submit" VALUE="login">
</FORM>
';
echo '<a target="iframe" href="wachtverg.php?verstuurd=nee">Wachtwoord vergeten?</a><BR>';
echo '<a target="iframe" href="formulier.html">Registreren</a><BR>';
}
?>
if ($login == "ja") {
include("dbconnect.php");
$query = mysql_query("SELECT * FROM leden WHERE username = '$username' AND password = '$password'");
$tabel = mysql_fetch_array($query);
if ($tabel[username] == "" && $tabel[password] == "") {
echo '
U hebt geen of verkeerde gegevens ingevult.<BR>
Klik op vorige in uw browser en vul nu wel iets in.
';
}
else {
session_start();
header("Cache-control: private");
echo "Username: $tabel[username]<BR>";
echo "Id: $tabel[id]<BR>";
echo "Your session ID is <strong>". session_id() ."</strong><BR>";
echo "Saldo: $tabel[saldo]<BR><BR>";
echo '<a target="_top" href="index.php?login="><B>Uitloggen<B></a><BR>';
echo '<a target="iframe" href="games.php">Games</a><BR>';
echo '<a target="iframe" href="nbs.html">Bestellen</a><BR>';
echo '<BR><BR><BR><BR><BR><BR>';
$_SESSION['username'] = $tabel[username];
$_SESSION['password'] = $tabel[password];
}
}
else {
session_start();
header("Cache-control: private");
$_SESSION['username'] = FALSE;
$_SESSION['password'] = FALSE;
session_destroy();
if($_SESSION['username']){
echo "The session is still active";
} else {
echo "$_SESSION[password] Ok, the session is no longer active! <br />";
}
echo '<B>U bent niet ingelogd</B>';
echo '
<FORM NAME="formulier" ACTION="index.php" METHOD="post">
Username:<INPUT TYPE="text" NAME="username"><BR>
Wachtwoord:<INPUT TYPE="password" NAME="password"><BR>
<input type="hidden" name="login" value="ja">
<INPUT TYPE="Submit" NAME="Submit" VALUE="login">
</FORM>
';
echo '<a target="iframe" href="wachtverg.php?verstuurd=nee">Wachtwoord vergeten?</a><BR>';
echo '<a target="iframe" href="formulier.html">Registreren</a><BR>';
}
?>
///////////////////////// games pagina
Code (php)
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
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
<?php
session_start();
header("Cache-control: private");
echo "Your session ID is <strong>". session_id() ."</strong><BR>";
echo '
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="30%" id="AutoNumber1">
<tr>
<td width="100%">Games</td>
</tr>
<tr>
<td width="100%"> </td>
</tr>
<tr>
<td width="100%"><a href="games/roulette/roulette.php?username=$username">
Roulette</a></td>
</tr>
<tr>
<td width="100%"><a href="nbs.html">
Numbergame</a></td>
</tr>
<tr>
<td width="100%"><a href="nbs.html">
Loterij</a></td>
</tr>
<tr>
<td width="100%">';
print ("$username");
echo '
</td>
</tr>
</table>
</center>
';
?>
session_start();
header("Cache-control: private");
echo "Your session ID is <strong>". session_id() ."</strong><BR>";
echo '
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="30%" id="AutoNumber1">
<tr>
<td width="100%">Games</td>
</tr>
<tr>
<td width="100%"> </td>
</tr>
<tr>
<td width="100%"><a href="games/roulette/roulette.php?username=$username">
Roulette</a></td>
</tr>
<tr>
<td width="100%"><a href="nbs.html">
Numbergame</a></td>
</tr>
<tr>
<td width="100%"><a href="nbs.html">
Loterij</a></td>
</tr>
<tr>
<td width="100%">';
print ("$username");
echo '
</td>
</tr>
</table>
</center>
';
?>
sorry vooor het 2 keer posten deze kan wel verwijderd worden