sessions...urgent

Problems with the Windows version of XAMPP, questions, comments, and anything related.

sessions...urgent

Postby mcog_esteban » 02. December 2004 16:18

hi all.
can someone help me with this:
i'm having a strange problem using sessions,i have a login system based on sessions, and sometimes i can't login, the problem is that i can indeed login but the page creates another session id,sending me back to the login page, i get the tmp dir full of sess_*************** files with 0kb.First i thought that was something wrong with my code, and i did the simplest system i know:

login.html


Code: Select all
<html>
<body>
<form method="post" action="login.php">
<input type="text" name="user"><br>
<input type="text" name="pass">
<input type="submit" name="submit" value="send">
</form>
</body>
</html>
?>



login.php



Code: Select all

<?php
session_start();

if($_POST['submit'])
{
  if($_POST['user']=="master")
  {
    if($_POST['pass'] == "blaster")
    {
       session_register('user');
       $_SESSION['user']=$_POST['user'];
       header("Location: secret.php");
       exit;
    }
  }
  else
  {
    echo "Login or Password wrong<br>";
    <a href="login.html">Click here to login again.</a>
   }
}
?>

secret.php

Code: Select all
<?php
session_start();

if(!empty($_SESSION['login']))
{
   echo "Welcome to the secret page";
}
else
{
  <a href="login.html">You have to login to access this page
}
?>




and it didn't work....a few hours later it worked.
i really don't know what to do anymore.

if it helps, i'm running this on Windows XP + SP2

if anybody knows or have clue, please let me know.
thanks
mcog_esteban
 
Posts: 10
Joined: 02. December 2004 16:13

Re: sessions...urgent

Postby MacDaddy » 04. December 2004 12:43

mcog_esteban wrote:hi all.
can someone help me with this:
i'm having a strange problem using sessions,i have a login system based on sessions, and sometimes i can't login, the problem is that i can indeed login but the page creates another session id,sending me back to the login page, i get the tmp dir full of sess_*************** files with 0kb.First i thought that was something wrong with my code, and i did the simplest system i know:

login.html


Code: Select all
<html>
<body>
<form method="post" action="login.php">
<input type="text" name="user"><br>
<input type="text" name="pass">
<input type="submit" name="submit" value="send">
</form>
</body>
</html>
?>



login.php



Code: Select all

<?php
session_start();

if($_POST['submit'])
{
  if($_POST['user']=="master")
  {
    if($_POST['pass'] == "blaster")
    {
       session_register('user');
       $_SESSION['user']=$_POST['user'];
       header("Location: secret.php");
       exit;
    }
  }
  else
  {
    echo "Login or Password wrong<br>";
    <a href="login.html">Click here to login again.</a>
   }
}
?>

secret.php

Code: Select all
<?php
session_start();

if(!empty($_SESSION['login']))
{
   echo "Welcome to the secret page";
}
else
{
  <a href="login.html">You have to login to access this page
}
?>




and it didn't work....a few hours later it worked.
i really don't know what to do anymore.

if it helps, i'm running this on Windows XP + SP2

if anybody knows or have clue, please let me know.
thanks


why not just use .htaccess ? its a little easyer than a hackable .php with the password in it.
Image
User avatar
MacDaddy
 
Posts: 38
Joined: 11. November 2004 14:26
Location: Australia

Postby alfa_schumi » 04. December 2004 13:14

In the secret.php page you check if "$_SESSION['login']" is not empty, while in the login.php you put the user in "$_SESSION['user']" try changing login to user in the secret.php page.
alfa_schumi
 
Posts: 1
Joined: 02. December 2004 10:36

Postby Maller » 06. December 2004 17:52

Dude, storing passwords in .php files is not a good idea, storing uncrypted passwords is even worse.
Use a database to store your passwords, and encrypt them.

If you really have to store the password in the php file, atleast use md5() to encrypt em, as it´s almost impossible to crack.
User avatar
Maller
 
Posts: 49
Joined: 06. March 2004 14:47


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 119 guests