View previous topic :: View next topic |
Author |
Message |
yupsie -
Joined: 31 Jul 2003 Posts: 5
|
Posted: Thu Jul 31, 2003 8:31 pm Post subject: php sessions |
|
|
why is my session away after an Header('Location: ...'); or an <script>window.location.href='';</script>
the session is running everywhere but not after such a redirect
i always have session_start(); on top of the page
help!
thnx! |
|
Back to top |
|
 |
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Fri Aug 01, 2003 6:10 pm Post subject: Re: php sessions |
|
|
yupsie wrote: | why is my session away after an Header('Location: ...'); or an <script>window.location.href='';</script>
the session is running everywhere but not after such a redirect
i always have session_start(); on top of the page
help!
thnx! |
This was a problem in Abyss Web Server version 1.15 and prior. Please redo your tests with version 1.1.6 and let us know if it works. If not, please include a sample script. _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
 |
CapFusion -
Joined: 18 May 2003 Posts: 617 Location: Lost in Abyss' Dungeon
|
Posted: Sat Aug 02, 2003 1:04 am Post subject: |
|
|
Quote: | This was a problem in Abyss Web Server version 1.15 and prior. Please redo your tests with version 1.1.6 and let us know if it works. If not, please include a sample script. |
What is X1 Update X1? Is this prior to 1.1.5 or something older? _________________ CapFusion,... |
|
Back to top |
|
 |
yupsie -
Joined: 31 Jul 2003 Posts: 5
|
Posted: Sat Aug 02, 2003 2:55 am Post subject: Re: php sessions |
|
|
aprelium wrote: |
This was a problem in Abyss Web Server version 1.15 and prior. Please redo your tests with version 1.1.6 and let us know if it works. If not, please include a sample script. |
i already have the 1.1.6 edition but its still the same problem
Code: |
<?
Header('Location: index15.php');
?>
|
my code is on the different pages with a header, guess no more than the header line is required of them, guess there's a problem in my index15.php then:
Code: |
<? session_start();
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
$db = mysql_connect('localhost', 'root') or die (mysql_error());
$db_select = mysql_select_db('sase', $db) or die (mysql_error());
if($_SERVER['REQUEST_METHOD'] == 'POST') { //1
$query = mysql_query("SELECT * FROM members WHERE nick='".$_POST['nick']."' AND paswoord='".$_POST['paswoord']."'");
$aantal = mysql_num_rows($query);
if ($aantal != 0) { //2
$_SESSION['nick'] = $_POST['nick'];
} //2
if ($_POST['action'] == 'forgot') {
$result = mysql_query("SELECT * FROM members WHERE nick='".$_POST['nick']."'");
while ($forgot = mysql_fetch_array($result)) {
$ww = $forgot['paswoord'];
$email = $forgot['email'];
}
$subject = "SASE Website -- Wachtwoord vergeten";
$text = "Hierbij ontvang je je wachtwoord, deze is door jouzelf of door een ander ingevuld in het formulier 'Wachtwoord vergeten':\n";
$text .= "Loginnaam: ".$_POST['nick']."\n";
$text .= "Wachtwoord: $ww\n";
mail($email, $subject, $text, "From: SASE Website");
}
} //1
if ($_GET['log'] == "out") {
$logout = mysql_query("UPDATE members SET logged='0' WHERE nick='".$_SESSION['nick']."'", $db);
session_destroy();
}
$login = mysql_query("UPDATE members SET logged='1', time='$timestamp' WHERE nick='".$_SESSION['nick']."'", $db);
echo "<html>"; include("menu.php");
?>
|
and maybe the code of menu.php is required too:
Code: |
<?
$db = mysql_connect('localhost', 'root') or die (mysql_error());
$db_select = mysql_select_db('sase', $db) or die (mysql_error());
$timestamp = time();
$query_logged_members = mysql_query("SELECT * FROM members WHERE logged='1'", $db);
while ($sel = mysql_fetch_array($query_logged_members)) {
$time = $sel['time'];
$timeout = $time - $timestamp;
$timesec = 300;
$timeouts = $timeout + $timesec;
if ($timeouts <= "0") {
mysql_query("UPDATE members SET logged='0' WHERE time='$time'", $db);
}
}
?>
|
The two database connects are needed because menu.php is included into all of the pages[/code] |
|
Back to top |
|
 |
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Sat Aug 02, 2003 3:57 pm Post subject: Re: php sessions |
|
|
We're investigating the issue. Meanwhile, we recommend using a global redirection (using the full URL of the index15.php script):
Code: |
<?
Header('Location: http://yoursite/path/index15.php');
?>
|
This should solve the problem as the redirection will be handled by the browser and not internally by the server. _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
 |
yupsie -
Joined: 31 Jul 2003 Posts: 5
|
Posted: Sat Aug 02, 2003 6:12 pm Post subject: |
|
|
doesn't work either, i tried the absolute URL but it still logs out after a redirect, so i'll wait for the investigation
thnx |
|
Back to top |
|
 |
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Mon Aug 11, 2003 12:23 pm Post subject: |
|
|
yupsie,
We did the tests and it seems that you PHP configuration or your code has a problem.
The test was reduced to the following two files:
redir.php
Code: | <?php
session_start();
session_register("count");
$count = 1000;
Header('Location: result.php');
?> |
and result.php
Code: | <?php
session_start();
echo "count=",$_SESSION['count'];
?> |
When you browse the first file, you are redirected and count=1000 should be displayed. If session do not work properly, an error occurs after the redirection.
This test works when sessions use cookies. If not, there might be some problems (may be it's your case).
To set sessions to use cookies, open php.ini and replace
Code: | session.use_cookies = 0 |
with
Code: | session.use_cookies = 1 |
_________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
 |
|