Results 1 to 5 of 5

Thread: Cookies === Arghhhh *Fixed*

  1. #1

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065

    Cookies === Arghhhh *Fixed*

    OK,

    After god knows how many problems i got, writing my "Exchange" purely from scratch,

    I decided i WOULD use php-nuke as a "Base" Application,

    Hacked it as i needed it, ETC,

    But that aint my problem, i got it all working, SO FAR,

    EXCEPT COOKIES!


    I put this:

    PHP Code:

     
    if ($_COOKIE['referer']==""){
        if(
    $ref !=""){
                
    setcookie("referer",$ref,time()+7200);
                
    $refer=$ref;
        }
     } else {
        
    $refer=$_COOKIE['referer'];
     } 
    Into my header.php (Very top of the file),

    And if i call my page like:

    http://adz.ods.org:88/modules.php?na...&ref=wpearsall

    It will set the cookie, etc properly, even when u go from the page, and back to it, it stays in the browser

    (well for 2 hours, plenty of time for some1 to sign up i think huh)

    However:

    If i call the page via:

    http://adz.ods.org:88/index.php?ref=wpearsall

    IT WILL NOT SET THE COOKIE.


    Now, I Dont got ANY idea why : Freaky stuff huh :

    Now, i have got "register_globals" set to "On", etc, and stuff,

    So im guessing its probally some STUPID mistake i've done.

    Now: Most Likely i guess its i've use:
    "$ref", i know theres another method, : I dont know what though : to get the post variables,

    If ne 1 can help. it would be brill

    Tnx,
    Wayne
    Last edited by wpearsall; Oct 15th, 2002 at 08:35 PM.
    Wayne

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Try $_REQUEST['ref']

    and if you're using it as a url variable, it's a get variable, not a post.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    Oh yeah, so it is

    Tnx
    Wayne

  4. #4
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    if you use this
    PHP Code:
    if ($_COOKIE['referer']==""){
        if(
    $ref !=""){
                
    setcookie("referer",$ref,time()+7200);
                
    $refer=$ref;
        }
     } else {
        
    $refer=$_COOKIE['referer'];
     } 
    the script doesn't know what ref is? even after you setcookie $ref is still empty. try this

    PHP Code:
    if ($_COOKIE['referer']==""){
        if(
    $_REQUEST['ref'] != ""){
                
    setcookie("referer",$ref,time()+7200);
                
    $refer=$ref;
        }
     } else {
        
    $refer=$_COOKIE['referer'];
     } 

  5. #5

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    I used :

    PHP Code:
    if ($_COOKIE['referer']==""){
        if(
    $_REQUEST['ref'] != ""){
                
    setcookie("referer",[b]$_REQUEST['ref'][/b],time()+7200);
                
    $refer=[b]$_REQUEST['ref'][/b];
        }
     } else {
        
    $refer=$_COOKIE['referer'];
     } 

    And it fixed it

    : Forgot to change post tho to *Fixed* *changes now*:
    Wayne

Posting Permissions

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



Click Here to Expand Forum to Full Width