Thread: cookies

Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    53
    Rep Power
    14
    How do I print a value which the cookie contains?
  2. #2
  3. Ole` Timer
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Location
    N.W. Iowa
    Posts
    472
    Rep Power
    14
    This all depends on how your retreiving the cookie. If your using the CGI module it's simply:

    $cookie_value = cookie('cookie_name');

    Provided the cookie was past by the same domain that's retrieving the cookie.

    Mickalo

    Thunder Rain Internet Publishing

    Custom Programming & Database development
    Providing Personal/Business
    Internet Solutions that work!
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    53
    Rep Power
    14
    In what ways can I retrieve it? How?
  6. #4
  7. Ole` Timer
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Location
    N.W. Iowa
    Posts
    472
    Rep Power
    14

    Thumbs up


    What programming language are you using?? Perl?? As I say, using the CGI module with your script, is the easiest way. You can generate your own routines to pass or retreive cookies, or use the cookie.lib written by Matt Wright. But using CGI module is the easiest way,..with Perl. PHP seems to utilize the same process as Perl does with the CGI module.

    Mickalo

    Thunder Rain Internet Publishing

    Custom Programming & Database development
    Providing Personal/Business
    Internet Solutions that work!
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    53
    Rep Power
    14
    hmm.. i will be using perl.. i can do it in php.. but got kinda lost in perl... could you should me some sample code?

    if the cookie name was "help", then what would the code look like?
  10. #6
  11. Ole` Timer
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Location
    N.W. Iowa
    Posts
    472
    Rep Power
    14
    You need to shift over to the PHP forum to find out about using PHP, but using Perl to retreivie a cookie named help would look something like this:
    Code:
    #!/usr/bin/perl -w
    ##################################
    use CGI qw/:standard/;
    use CGI::Carp qw(fatalsToBrowser);
    use strict;
    
    my $cookie_name = cookie('help');
    # Now the $cookie_name holds the value of 'help'
    print header();
    print start_html()
    print qq|My Cookie is $cookie_name|;
    print end_html();
    exit;
    Mickalo

    Thunder Rain Internet Publishing

    Custom Programming & Database development
    Providing Personal/Business
    Internet Solutions that work!
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    53
    Rep Power
    14
    Thanx, Ill give this a shot
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    53
    Rep Power
    14
    It gave me this error

    <quote>
    Software error:
    Execution of test.cgi aborted due to compilation errors.
    </quote>
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    53
    Rep Power
    14
    I cut and pasted exactly what you gave me
  18. #10
  19. Ole` Timer
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Location
    N.W. Iowa
    Posts
    472
    Rep Power
    14
    Originally posted by kunal
    I cut and pasted exactly what you gave me
    forgot a semi colon, should be:
    print start_html();

    Plus you have to have a cookie named "help" set in order to retrieve it. You may to check into Stein's book using CGI.pm! Great book

    Mickalo

    Thunder Rain Internet Publishing

    Custom Programming & Database development
    Providing Personal/Business
    Internet Solutions that work!
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    53
    Rep Power
    14
    hmmm.. it doesnt give any errors.. but it doesnt print out the value of the cookie
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    53
    Rep Power
    14
    HELP
    kunal
    http://www.kunal.net/cgi-bin/bleep/
    0
    51331456
    29470289
    864021984
    29396946
    *



    this is what the cookie contains.. and the cookie exists.. i dunn see any reason why it shouldnt print it out.. any ideas?
  24. #13
  25. Ole` Timer
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Location
    N.W. Iowa
    Posts
    472
    Rep Power
    14

    Thumbs up


    You have to set the cookie called "help" first, then you can retrieve it!

    Mickalo

    Thunder Rain Internet Publishing

    Custom Programming & Database development
    Providing Personal/Business
    Internet Solutions that work!
  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    53
    Rep Power
    14
    HELP
    kunal
    http://www.kunal.net/cgi-bin/bleep/
    0
    51331456
    29470289
    864021984
    29396946
    *


    this is what the cookie contains.. and the cookie exists.. i dunn see any reason why it shouldnt print it out.. any ideas?
  28. #15
  29. Ole` Timer
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Location
    N.W. Iowa
    Posts
    472
    Rep Power
    14

    Question


    How are you setting the cookie?? What is the name of the cookie your trying to retrieve. Each cookie has a name which is associated to a value: cookie name = it's value. If you set a cookie named "help" it must have a value attached to it.

    Mickalo

    Thunder Rain Internet Publishing

    Custom Programming & Database development
    Providing Personal/Business
    Internet Solutions that work!
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo