Webserver setting: Php version 4.1.2

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
marketingtops.com
Forum Newbie
Posts: 1
Joined: Fri Nov 28, 2003 7:24 am

Webserver setting: Php version 4.1.2

Post by marketingtops.com »

Webserver setting: Php version 4.1.2

I am writing a login page by using $_SESSION[].
I tested it on my local computer(localhost), it works fine.
However, when I uploaded to the webserver, it doesn't work propertly. It displayed the error message that what I created "Failed to login, this is a restricted page".
I can login into the first page, when I click the second page links, it can't log me in unless I refresh this page several times.

For example, I have 3 pages, login.php, firstpage.php, and secondpage.php
Code on firstpage.php and secondpage.php
if(!isset($_SESSION['valid_admin'])) {
//Error message if it failed to login.
die("Failed to login, this is a restricted page.");
}
print("Logined successful. <i>Welcome < ".$_SESSION['valid_adm']."> </i>");

I type the username and password on login.php,
I can log in to firstpage.php,
when I click the link of secondpage.php on firstpage.php,
I cannot log in until I clicked the "Refresh" button on IE several times.
I don't know what causes this problem? Is it because my webserver is too slow since this webserver have a lot of traffic?
Did anyone know what happened? Please, help me if you knew the solution.
Thank you,

Raindrops,
http://www.marketingtops.com
Joan Garnet
Forum Newbie
Posts: 19
Joined: Fri Jun 20, 2003 9:56 am
Location: Barcelona

Post by Joan Garnet »

An example of using sessions:

session1.php -> create a session

Code: Select all

<?php
session_start(); 
header("Cache-control: private"); // prevents bug ie6
?>
<FORM METHOD="POST" ACTION="session2.php">
Enter your Name: <input type="text" name="name">
<input type="SUBMIT" value="Submit">
</FORM>
session2.php -> register some var sessions

Code: Select all

session_start(); 
header("Cache-control: private"); 
$identification = session_id();
$name = $_POST['name'];
session_register('name');
$_SESSION['name'] = $name;
 echo "<a href="session3.php"><< unregister session</a>";
session3.php -> unregister session

Code: Select all

session_start();
header("Cache-control: private");
// in this page we unregister the "name" session var
session_unregister('name'); // or session_destroy(); to completely remove all vars

if(session_is_registered('name')){
    echo "The session is still registered.";
} else {
    echo "The session is no longer registered! <br />";
    echo "<a href="session1.php"><< Go Back Step 1</a>";
}
I think that can help...
Post Reply