Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old February 6th, 2001, 05:20 AM
kunal kunal is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 53 kunal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to kunal
How do I print a value which the cookie contains?

Reply With Quote
  #2  
Old February 6th, 2001, 06:54 AM
mickalo's Avatar
mickalo mickalo is offline
Ole` Timer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Location: N.W. Iowa
Posts: 469 mickalo User rank is Private First Class (20 - 50 Reputation Level)mickalo User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 5 h 19 sec
Reputation Power: 8
Send a message via AIM to mickalo Send a message via MSN to mickalo
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!

Reply With Quote
  #3  
Old February 6th, 2001, 07:19 AM
kunal kunal is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 53 kunal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to kunal
In what ways can I retrieve it? How?

Reply With Quote
  #4  
Old February 6th, 2001, 07:31 AM
mickalo's Avatar
mickalo mickalo is offline
Ole` Timer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Location: N.W. Iowa
Posts: 469 mickalo User rank is Private First Class (20 - 50 Reputation Level)mickalo User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 5 h 19 sec
Reputation Power: 8
Send a message via AIM to mickalo Send a message via MSN to mickalo
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

Reply With Quote
  #5  
Old February 6th, 2001, 07:38 AM
kunal kunal is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 53 kunal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to kunal
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?

Reply With Quote
  #6  
Old February 6th, 2001, 07:44 AM
mickalo's Avatar
mickalo mickalo is offline
Ole` Timer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Location: N.W. Iowa
Posts: 469 mickalo User rank is Private First Class (20 - 50 Reputation Level)mickalo User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 5 h 19 sec
Reputation Power: 8
Send a message via AIM to mickalo Send a message via MSN to mickalo
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

Reply With Quote
  #7  
Old February 6th, 2001, 07:47 AM
kunal kunal is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 53 kunal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to kunal
Thanx, Ill give this a shot

Reply With Quote
  #8  
Old February 6th, 2001, 07:50 AM
kunal kunal is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 53 kunal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to kunal
It gave me this error

<quote>
Software error:
Execution of test.cgi aborted due to compilation errors.
</quote>

Reply With Quote
  #9  
Old February 6th, 2001, 07:51 AM
kunal kunal is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 53 kunal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to kunal
I cut and pasted exactly what you gave me

Reply With Quote
  #10  
Old February 6th, 2001, 07:58 AM
mickalo's Avatar
mickalo mickalo is offline
Ole` Timer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Location: N.W. Iowa
Posts: 469 mickalo User rank is Private First Class (20 - 50 Reputation Level)mickalo User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 5 h 19 sec
Reputation Power: 8
Send a message via AIM to mickalo Send a message via MSN to mickalo
Quote:
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

Reply With Quote
  #11  
Old February 6th, 2001, 08:16 AM
kunal kunal is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 53 kunal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to kunal
hmmm.. it doesnt give any errors.. but it doesnt print out the value of the cookie

Reply With Quote
  #12  
Old February 6th, 2001, 08:21 AM
kunal kunal is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 53 kunal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to kunal
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?

Reply With Quote
  #13  
Old February 6th, 2001, 08:21 AM
mickalo's Avatar
mickalo mickalo is offline
Ole` Timer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Location: N.W. Iowa
Posts: 469 mickalo User rank is Private First Class (20 - 50 Reputation Level)mickalo User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 5 h 19 sec
Reputation Power: 8
Send a message via AIM to mickalo Send a message via MSN to mickalo
Thumbs up

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

Mickalo

Reply With Quote
  #14  
Old February 6th, 2001, 08:25 AM
kunal kunal is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 53 kunal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to kunal
Quote:
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?

Reply With Quote
  #15  
Old February 6th, 2001, 08:44 AM
mickalo's Avatar
mickalo mickalo is offline
Ole` Timer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Location: N.W. Iowa
Posts: 469 mickalo User rank is Private First Class (20 - 50 Reputation Level)mickalo User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 5 h 19 sec
Reputation Power: 8
Send a message via AIM to mickalo Send a message via MSN to mickalo
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > cookies


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump