my cookies not seem to be working. the seesion works fine tho. am i missing some thing?
o and i doesnt print echo"on";

                if($remember_p == "on")
                {
                    //remember username for 42 hrs
                    setcookie("id", $id, time()+20); 
                    setcookie("username", $username_p, time()+20); //seconds 
                    //header("location: index.php");    
                    if(isset($_COOKIE['username']))
                    {
                    echo"on";
                    }
                }
                else if($remember_p == "")
                {
                    //create session variables
                    $_SESSION["id"] = $id;
                    $_SESSION["username"] = $username_p;
                    header("location: index.php");  
                }
Member Avatar for LastMitch

@hwoarang69

Try this

var_dump($_COOKIE);

in here:

if(isset($_COOKIE['username']))
{
var_dump($_COOKIE);
}

to see whether dump the cookie stuff, and also why are you using $id? Is this unique_id? You should store it in store a unique id instead of id to protect people from hacking.

commented: To Rectify what some retard did to LastMitch +0

i tried it and i get:
array(3) { ["id"]=> string(1) "1" ["username"]=> string(6) "person" ["PHPSESSID"]=> string(26) "fvvn7lflgchti7apsgcbeqd2u5" } on

so it seem to be getting the values. but it doesnt log me in.

Member Avatar for LastMitch

That's looks right. So the cookie is working!

Did you make sure your php.ini file allows cookies?

o wow. thanks i got it what the problem is.

also

is it ok, if i only have seesion username? and just remove seesion id
bc if i have session username than i can use sql to see there id and other stuff

Member Avatar for LastMitch

if ok if i only have seesion username? and just remove seesion id
bc if i have session username than i can use sql to see there id and other stuff

That is weird question you ask. You want to remove the session id? Why? The id is in the DB and when you login it needs to fetch the data to confirm. Does that make sense.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.