Announcement

Collapse
No announcement yet.

Grrrr.. Cookies!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Grrrr.. Cookies!

    I tried using this code to set a cookie

    Code:
    setcookie ("TestCookie", "test");
    I looked in c:\windows\Temporary Internet Files\
    and I didn't see my cookie,
    I also tried doing this to get the cookie

    Code:
    echo $TestCookie;
    //and even
    
    echo HTTP_COOKIE_VARS["TestCookie"];
    and nothing is working... Grrr...
    whats wrong?


    PS:
    what are magic quotes?
    Visual Basic, HTML, PHP, SQL, ASP, JavaScript, C++, Perl

    PHP 4.0.6
    MySQL 3.23.39
    Windows 2000

  • #2
    try this:
    Code:
      
    $time = time() +31536000; \\ expiration date
    $value = test; \\ value of the cookie
    setcookie('TestCookie',$value,$time);

    Comment


    • #3
      Don't they go in c:\Windows\Cookies?

      Comment


      • #4
        thanks Ed...
        I am so embarassed
        and thank you carp,
        but I still don't see my cookie, and I can't retrieve the value...
        Any Idea's?

        Thanks,
        Dennis
        Visual Basic, HTML, PHP, SQL, ASP, JavaScript, C++, Perl

        PHP 4.0.6
        MySQL 3.23.39
        Windows 2000

        Comment


        • #5
          by the way carp, your slashes are wrong

          Code:
          //this is a comment 2 front slashes
          
          \\this is causes a syntax error... kinda hard to catch
          if ya don't have them(//\\) back to back.. :o
          and although it works, I wouldn't recomend using variables that have the name of a function...... causes confusion, and IMO its bad programming practice

          My $0.02
          Visual Basic, HTML, PHP, SQL, ASP, JavaScript, C++, Perl

          PHP 4.0.6
          MySQL 3.23.39
          Windows 2000

          Comment


          • #6
            Cookies - my personal horror to program
            The little buggers never seem to work the way I tell them to
            - Insert viable disclaimer here -

            ArtBeast!

            Comment


            • #7
              *holds shot glass up, and hurridly downs it*

              I'm tryin' again!


              *downs shotglass after shotglass*

              Why isn't this working?

              Code:
              <?
              
              
              $times = time() + 31536000; // expiration date
              $value = "test"; // value of the cookie
              setcookie("TestCookie",$value,$times, "me.com");
              
              echo "D"; //I am using PWS v. 1 and if there is not output,
              //it thinks there is an error, so I have to do something :-\
              ?>
              Then I try this

              Code:
              echo $TestCookie;
              that doesn't work, and I can't see my cookie in the cookie directory
              Visual Basic, HTML, PHP, SQL, ASP, JavaScript, C++, Perl

              PHP 4.0.6
              MySQL 3.23.39
              Windows 2000

              Comment


              • #8
                $times is malformed - you have to use the mktime(..) function. Look in vB's global.php for an example.

                "me.com" isn't valid. You have to set that to a cookie path. ie, "/" or "/forums"

                Comment


                • #9
                  AAAAARRRRRRRRGGGGGGGHHHHH

                  pardon my french, but DAMNIT!

                  Code:
                  setcookie ("MyCookie","test",mktime()+3600, "/myfolder/php", "ci", 1);

                  Why isn't this working?

                  ci is my local host, /myfolder is a virtual directory, and /php is a directory inside of myfolder....

                  Visual Basic, HTML, PHP, SQL, ASP, JavaScript, C++, Perl

                  PHP 4.0.6
                  MySQL 3.23.39
                  Windows 2000

                  Comment


                  • #10
                    <!-- To the Top!!! -->

                    ^ ^


                    C'mon people... I need some help.... Doesn't anybody know anything about how to set cookies??

                    I've done it plenty of times in javascript, but I don't like javascript as much as PHP.

                    Visual Basic, HTML, PHP, SQL, ASP, JavaScript, C++, Perl

                    PHP 4.0.6
                    MySQL 3.23.39
                    Windows 2000

                    Comment


                    • #11
                      I don't see how this doesn't work, since it works very well for me:

                      Code:
                      setcookie("variablename",$variablevalue,time()+1800,"/",".yourdomain.com",0);

                      Comment


                      • #12
                        Grr...

                        I tried doing
                        Code:
                        echo setcookie("variablename",$variablevalue,time()+1800,"/",".yourdomain.com",0);

                        To see if it succeeded, it did because it echoed 1,
                        but I looked for my cookie, and I couldn't find it, and I couldn't retrieve the value with

                        Code:
                        echo $variablename;

                        Thanks,
                        Dennis
                        Visual Basic, HTML, PHP, SQL, ASP, JavaScript, C++, Perl

                        PHP 4.0.6
                        MySQL 3.23.39
                        Windows 2000

                        Comment


                        • #13
                          You did replace yourdomain.com with your domain right?

                          Comment


                          • #14
                            Here's the code I use:

                            Code:
                            setcookie("username", $username, time() + 31536000, "/");
                            Works OK for me...

                            BTW... you DO have cookies enabled, right?

                            Comment


                            • #15
                              Yep, cookies enabled, Nope, don't have a domain....
                              I tried using
                              ci << computer name
                              localhost << localhost, works same as computer name
                              192.168.1.1 << intranet IP
                              and my `real` internet IP


                              Thanks,
                              Dennis
                              Visual Basic, HTML, PHP, SQL, ASP, JavaScript, C++, Perl

                              PHP 4.0.6
                              MySQL 3.23.39
                              Windows 2000

                              Comment

                              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                              Working...
                              X