PHP setting cookies problem

Discussion in 'Software' started by Wookie, Nov 9, 2004.

  1. Wookie

    Wookie Sergeant Major

    ok I have one page login.php that sets this
    Code:
    setcookie("val", "yes", time()+36000);
    	setcookie("usernm", $nm, time()+36000);
    	setcookie("pass", $ps, time()+36000);
    	header('location:timesheet.php');
    
    I get to timesheet.php I get the cookie info just fine. I have another page that is a link inside timesheet.php called description.php when I try to get the cookie info I get nothin. Heres my code
    Code:
    if (isset($_COOKIE["val"]) && isset($_COOKIE["usernm"]) && isset($_COOKIE["pass"])){
    
    	$val = $_COOKIE["val"];
    
    	$usernm = $_COOKIE["usernm"];
    
    	$pass = $_COOKIE["pass"];
    
    }
    
    

    same exact code that is in timesheet.php but it does not work I always get the else which says not authorized. If anyone knows what golden rule I am missing here about cookies I would appreciate the help. Thanks.
     
  2. BrokenArrows

    BrokenArrows Sergeant

    Hey i dont know the answer to you problem but i was just wondering would it not be a bit of a security risk putting the username and password in a cookie.

    Just a thought!

    But just as a guess would timesheet.php be altering the cookie in any way.
     
  3. Wookie

    Wookie Sergeant Major

    the password is encrypted. its a 40 string sha1 encryption on a small web page no body but 5 employees will know about. Im not to worried about it but if I start to worry ill do sha1 + md5 encryption in both the username and password. Have fun crackin that.
     
  4. goldfish

    goldfish Lt. Sushi.DC

    No problem with putting those vars into a cookie, but personally I'd use a session. But thats just me.

    Have you thought it might be a browser problem? Or are you certain its php thats causing it.
     
  5. Wookie

    Wookie Sergeant Major

    What function sets session cookies I would prefer the cookies are eradicated when the browser closes. I tried it under firefox 1.0 and IE 6 with same issue.
     
  6. Kodo

    Kodo SNATCHSQUATCH

    ahh c'mon.. you knew somene was gonna do it sooner or later. :p
     

    Attached Files:

  7. Wookie

    Wookie Sergeant Major

    Kodo I lub j00 man
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds