Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New to the CF scene
    Join Date
    Sep 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Session's working but cookies won't store

    Hello,

    Here's my problem,

    I'm working on my gallery script and my cookies don't seem to work, I am not sure if it has anything to do with the fact that i'm using mod_rewrite or not.

    i've used this code on several sites of mine and they all work fine. my friend recommended to make an OOP version of it, but i'm not so sure how to i know basic OOP but not enought to make anythign with it.. anyway here's my code.


    login.php
    PHP Code:
    <?php
    if($remember == "on") {
         
    $cookiedata $r->username.'-'.$r->password;
         
    setcookie("******-*****"$cookiedatatime()+31536000);
    }
    ?>
    header.php
    PHP Code:
    <?php
    if(isset($_COOKIE['******-*****'])){
        
    $cookiedata explode("-"$_COOKIE['******-*****']);
        
    $cookie_user $cookiedata[0];
        
    $cookie_pass $cookiedata[1];
        
    $query_user "SELECT * FROM `users` WHERE `username` = '$cookie_user' AND `password` = '$cookie_pass'";
        
    $exec_user mysql_query($query_user) or die(mysql_error());
        if(
    mysql_num_rows($exec_user) == 0) {
            
    header('location: http://www.silentchamber.co.uk/index/');
            require(
    'inc/footer.php');
            exit;
        }
        else {
            while(
    $r_user=mysql_fetch_object($exec_user)){
                
    $userid $r_user->id;
                
    $username $r_user->username;
                
    $userdisplay $r_user->displayname;
                
    $access $r_user->access;
            }
            
    session_register('******-*****');
            
            
    $_SESSION['username'] = $username;
            
    $_SESSION['displayname'] = $userdisplay;
            
    $_SESSION['userid'] = $userid;
            
    $_SESSION['useraccess'] = $access;
            
            }
        }
    ?>

    reason why i think it is the mod rewrite causing the problem because i've noticed that in the dir with header.php it works but header is included into the index.php file..


    hope someone can help me with this.


    Regards,



    Neil Hickman

    Company Director, SilentChamber Photography <silentchamber.co.uk>

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Quote Originally Posted by SilentChamber
    my cookies don't seem to work
    Way too vague to be any help.

  • #3
    New to the CF scene
    Join Date
    Sep 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fumigator
    Way too vague to be any help.

    What i mean by that is the cookie isn't set at all, i have cookie editors and none of them can find that cookie anywhere even after the script is run.

  • #4
    Regular Coder
    Join Date
    Aug 2006
    Location
    UK, London, Dartford
    Posts
    221
    Thanks
    3
    Thanked 14 Times in 14 Posts
    havnt set the path:
    PHP Code:
    setcookie("******-*****"$cookiedatatime()+31536000'/'); 

  • #5
    New to the CF scene
    Join Date
    Sep 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok i've set the path, and it still doesn't create the cookie, theres no trace of it anywhere

  • #6
    Regular Coder
    Join Date
    Aug 2006
    Location
    UK, London, Dartford
    Posts
    221
    Thanks
    3
    Thanked 14 Times in 14 Posts
    Ok can you explain this for me.
    PHP Code:
    $cookiedata $r->username.'-'.$r->password;
    setcookie("******-*****"$cookiedatatime()+31536000); 
    if '$cookiedata' is there username and password, whats the session name?

  • #7
    New to the CF scene
    Join Date
    Sep 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Lee Stevens
    Ok can you explain this for me.
    PHP Code:
    $cookiedata $r->username.'-'.$r->password;
    setcookie("******-*****"$cookiedatatime()+31536000); 
    if '$cookiedata' is there username and password, whats the session name?
    the session name is the same as the cookie name... all RCBLOG-LOGIN

  • #8
    Regular Coder
    Join Date
    Aug 2006
    Location
    UK, London, Dartford
    Posts
    221
    Thanks
    3
    Thanked 14 Times in 14 Posts
    So is it actuly set to that in your scripts not *******-*******

  • #9
    New to the CF scene
    Join Date
    Sep 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Lee Stevens
    So is it actuly set to that in your scripts not *******-*******
    yes it is..

  • #10
    Regular Coder
    Join Date
    Aug 2006
    Location
    UK, London, Dartford
    Posts
    221
    Thanks
    3
    Thanked 14 Times in 14 Posts
    PHP Code:
    setcookie("RCBLOGLOGIN",   $cookiedata,   time()+31536000'/'); 
    Try it whith out the '-' amd see if it works.... thats the only thing i can think of inless your useing it in a function or something....

    Edit:
    PHP Code:
    <?php
    if($remember == "on") {
         
    $cookiedata $r->username.'-'.$r->password;
         
    setcookie("******-*****"$cookiedatatime()+31536000'/');
    }
    ?>
    $r->username & $r->password arnt in the IF statment so it probley wont no what the values are, try:

    PHP Code:
    <?php
    if($remember == "on") {
         
    $cookiedata $_POST['username'].'-'.$_POST['password'];
         
    setcookie("******-*****"$cookiedatatime()+31536000'/');
    }
    ?>
    Last edited by Lee Stevens; 09-04-2006 at 10:15 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
    •