furious_gamer
Excessive happiness
Guys, i was completely running out of idea when it comes to session tracking. I previously do the session management in JSP/Servlet using the database to store the user's session related details,temporarily,say until he logs out.
Now after i moved to PHP, i was so glad to see that the default session handling offered by PHP is so good to consider. But the problem is how to use the default session handling efficiently.
Consider a scenario i come up with :
After the user presses logout, i just unregister the session variable and destroy the session. But when i try to click the back button of the browser, it say "The Page you are trying to view contains POSTDATA that has expired from cache. If you resend the data, any action the form carried out(such as a search or online purchase) will be repeated. To resend the data, click OK. Otherwise , click Cancel".
After i press OK, it then go back to the previous page, which is only viewable to authorized users.
In my program i have three pages . ( A Simple session management program using PHP)
1. login.php
2.welcome.php
3.logout.php
login.php doesnt contain any php code. It simply has two textfields for username and password and a Submit button.
welcome.php
logout.php
Please let me know whats wrong with my code. I dont want to use database to track the users session. So please try to help me with the default session tracking offered by PHP.
Now after i moved to PHP, i was so glad to see that the default session handling offered by PHP is so good to consider. But the problem is how to use the default session handling efficiently.
Consider a scenario i come up with :
After the user presses logout, i just unregister the session variable and destroy the session. But when i try to click the back button of the browser, it say "The Page you are trying to view contains POSTDATA that has expired from cache. If you resend the data, any action the form carried out(such as a search or online purchase) will be repeated. To resend the data, click OK. Otherwise , click Cancel".
After i press OK, it then go back to the previous page, which is only viewable to authorized users.
In my program i have three pages . ( A Simple session management program using PHP)
1. login.php
2.welcome.php
3.logout.php
login.php doesnt contain any php code. It simply has two textfields for username and password and a Submit button.
welcome.php
PHP:
<?
session_start();
$username = $HTTP_POST_VARS["username"];
$password = $HTTP_POST_VARS["password"];
if($username=="somedata" && $password=="someotherdata")
{
echo "Authorized user";
session_register("username");
echo "<a href="logout.php'>Log Out</a>";
}
else
{
echo "Un-authorized user";
echo "<a href="login.php">Go Back</a>";
}
?>
logout.php
PHP:
<?
session_start();
if(session_is_registered("username"))
{
session_unregister("username");
session_destroy();
}
else
{
echo "Unknown call to this page.";
}
?>
Please let me know whats wrong with my code. I dont want to use database to track the users session. So please try to help me with the default session tracking offered by PHP.