Jump to content


Need help...strange problems with sessions.

  • Please log in to reply
No replies to this topic

#1 WilsonC

  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 30 October 2006 - 06:31 PM

Hi, i've been having problems with getting some sessions to work for me:

Initially, i had this code:

include 'dataconn.php';

// Conver to simple variables
$username = $_POST['username'];
$password = $_POST['password'];

if((!$username) || (!$password)){
    echo "Please enter ALL of the information! <br />";
    include 'loginform.htm';

$sql = mysql_query("SELECT AuthorNo, AuthorID, Email FROM Author WHERE AuthorID='$username' AND Pwd='$password' AND Status='1'");
$login_check = mysql_num_rows($sql);

if($login_check > 0){

    $row = mysql_fetch_array($sql);
    $today = time();
    $_SESSION['sessionLogin'] = $row[AuthorID];
    $_SESSION['sessionEmail'] = $row[email];
    $_SESSION['sessionLogintime'] = $MySQLdate;

    mysql_query("UPDATE Author SET Lastlogin='".$MySQLdate."' WHERE AuthorNo='".$_SESSION['author']."'");

    echo "You have successfully logged on, ".$_SESSION['sessionLogin']." at ".$_SESSION['sessionLogintime']."" ;

} else {
    echo "You could not be logged in! Either the username and password do not match or you have not validated your membership!<br />
        Please try again!<br />";
    include 'loginform.htm';



The above page seemed to work perfectly fine. However, if i added a hyperlink to, say "logintester.php",
and clicked on it:

if (isset($_SESSION['sessionLogin'])){
         $login = $_SESSION['sessionLogin'];
         $login = "Not Set";

echo "Welcome ". $login ." ";


It would return "Welcome Not Set", meaning the values of the session were not accessible on this next page. After scrounging through numerous forums and php sites, and trying various different approaches suggested by different people, i still could not get it to work. I tried testing my sessions with the following script:

if (session_id() == "") {
echo $_SESSION['count'];
echo $_SESSION['count'];
echo SID;

The first time the above script is run, it returns "12PHPSESSID=blablabla". Subsequent refreshes, however, returned just "12".

I've an incredibly strong feeling that this is caused by a really stupid oversight on my part, but i'm really getting frustrated at this. Any help would be deeply appreciated. I even tried switching webhosts but to no avail. For more information i'm using Byethost and infonet.com as testing servers for this.

Thanks in advance for any help anyone can give me.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users