Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2008
    Posts
    1

    Unanswered: Problem Maybe With Cookies in Subdomain

    Hi .
    I have a blog system and i working in local host well and I don't have any problem in local
    but after upload files in My host i cant login in admin section
    I think problem is Cookies!! and cookies not set ....
    after insert user/pass admin page redirect to :
    PHP Code:
    echo "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0;URL=index.php?index=$return\" />";
    (
    last line
    My Page Code :
    PHP Code:
    <?php
    require('../includes/db.php');
    require(
    '../includes/var.php');

    // This file contains all of the executable functionality for the admin section.

    // Login Authentication Section
    if($authentication){
        
    $auth_user mysql_query("SELECT * FROM authors");
        while(
    $au mysql_fetch_assoc($auth_user)){
            if(
    $username == $au['author_login'] && sha1($password) == $au['author_password']){
                
    $cookin setcookie("ba_admin",$au['author_id'],time()+7200);
                
    $unam $au['author_name'];
                echo 
    "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0;URL=index.php?index=main&unam=$unam\" />";
                return;
            }
        }
        if(!
    $cookin){echo "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0;URL=index.php?index=main&auth=fail\" />";return;}
    }

    // Logout routine
    if($logoff == "yes"){$cookout setcookie("ba_admin",$au['author_id'],time()-7200);$return="main";}

    // Login posting popup
    if($popauth){
        
    $pop_user mysql_query("SELECT * FROM authors");
        while(
    $pu mysql_fetch_assoc($pop_user)){
            if(
    $username == $pu['author_login'] && sha1($password) == $pu['author_password']){
                if(
    $pu['author_level'] > 2){echo "You must be an authorized post author to post on this blog.";return;}
                echo 
    "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0;URL=popost.php?in_auth=go&uaid=" $pu['author_id'] . "\" />";
                return;
                }
        }
        echo 
    "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0;URL=popost.php?auth=fail\" />";
        return;
    }

    // Login links popup
    if($linkauth){
        
    $pop_user mysql_query("SELECT * FROM authors");
        while(
    $pu mysql_fetch_assoc($pop_user)){
            if(
    $username == $pu['author_login'] && sha1($password) == $pu['author_password']){
                if(
    $pu['author_level'] > 1){echo "You must have Administrator access to put links on this blog.";return;}
                echo 
    "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0;URL=poplink.php?in_auth=go&uaid=" $pu['author_id'] . "\" />";
                return;
                }
        }
        echo 
    "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0;URL=poplink.php?auth=fail\" />";
        return;
    }

    // Author section
    if($add_author){
        if(
    $author_password == ""){echo "PASSWORD IS REQUIRED. Please go back and enter a valid password!";return;}
        
    $encrypted sha1($author_password);
        
    $author_about str_replace("'","\'",$author_about);
        
    $new_author = @mysql_query("INSERT INTO authors SET author_login='$author_login', author_password='$encrypted', author_name='$author_name', author_location='$author_location',     author_email='$author_email', author_photo='$author_photo', author_level='$author_level', author_about='$author_about'");
        if(!
    $new_author){echo "Adding new author failed with database error: " mysql_error() . ". Please report this error to the webmaster.";return;}
    }

    if(
    $update_author){
        
    $author_about str_replace("'","\'",$author_about);
        
    $upd_author = @mysql_query("UPDATE authors SET author_login='$author_login', author_name='$author_name', author_location='$author_location', author_email='$author_email', author_photo='$author_photo', author_level='$author_level', author_about='$author_about' WHERE author_id='$author_id'");
        if(!
    $upd_author){echo "Updating author information failed with database error: " mysql_error() . ". Please report this error to the webmaster.";return;}
    }

    if(
    $change_pw){
        
    $newpw sha1($newpw);
        
    $cnfpw sha1($cnfpw);
        
    $cp mysql_fetch_assoc(mysql_query("SELECT * FROM authors WHERE author_id='$author_id'"));
        if(
    $newpw != $cnfpw){echo "Your new and confirmed passwords do not match.";return;}
        if(
    $newpw === $cnfpw){
            
    $npw = @mysql_query("UPDATE authors SET author_password='$newpw'");
            if(!
    $npw){echo "Updating author password failed with database error: " mysql_error() . ". Please report this error to the webmaster.";}
            echo 
    "<p style=\"text-align:center;color:#990000;font-size:medium;font-weight:bold\">PASSWORD CHANGED</p>";
            echo 
    "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"1;URL=index.php?index=$return&getauth=" $cp['author_id'] . "\" />";return;
        }
    }

    if(
    $delete_author){
        
    $del_author = @mysql_query("DELETE FROM authors WHERE author_id='$author_id'");
        if(!
    $del_author){echo "Deleting author failed with database error: " mysql_error() . ". Please report this error to the webmaster.";return;}
    }

    if(
    $edit_author){echo "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0;URL=index.php?index=$return&getauth=$author_id\" />";return;}


    .
    .
    .
    .
    .
    .
    .
    .
    .
    .


    echo 
    "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0;URL=index.php?index=$return\" />";
    ?>

  2. #2
    Join Date
    Mar 2007
    Location
    010101010110100
    Posts
    803
    If your admin section resides in a sub-domain, you will have to check your php.ini file and make sure that you have the following line correct. This directive is blank by default.

    Code:
    session.cookie_domain = .yourdomain.com
    Note the period before the domainname.

  3. #3
    Join Date
    Jul 2008
    Posts
    13
    Shame on me.. I should have seen that. Maybe I was up late one night as I usually am.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •