Solved

Cookie problem

Posted on 2002-07-07
5
148 Views
Last Modified: 2013-12-25
Hi all,

I need to set a cookie in the client machine and then display some html content. The problem is, I am supposed to set the cookie using perl code which is an include file in a .shtml page.

Thanks in advance,
Vasavi.
0
Comment
Question by:vasavi
  • 4
5 Comments
 
LVL 5

Expert Comment

by:Peewee
Comment Utility
vasavi,

here is example use of setting a cookie within your perl script, there are many different ways of doing this:
 
use CGI qw/:standard/;
use CGI::Cookie;

    # Create new cookies and send them
    $cookie1 = new CGI::Cookie(-name=>'ID',-value=>123456);
    $cookie2 = new CGI::Cookie(-name=>'preferences',
                               -value=>{ font => Helvetica,
                                         size => 12 }
                               );
    print header(-cookie=>[$cookie1,$cookie2]);

============= feteching them ==================
    # fetch existing cookies
    %cookies = fetch CGI::Cookie;
    $id = $cookies{'ID'}->value;
    # create cookies returned from an external source
    %cookies = parse CGI::Cookie($ENV{COOKIE});

regards
Peewee

0
 
LVL 5

Expert Comment

by:Peewee
Comment Utility
vasavi,

a further example of setting a cookie:

 $c = new CGI::Cookie(-name    =>  'foo',
                             -value   =>  'bar',
                             -expires =>  '+3M',
                             -domain  =>  '.capricorn.com',
                             -path    =>  '/cgi-bin/database'
                             -secure  =>  1
                            );

a good resource site for cooies is: http://www.cookiecentral.com/

regards Peewee
0
 
LVL 5

Accepted Solution

by:
Peewee earned 75 total points
Comment Utility
vasavi,
did u get the answer you were looking for?

regards Peewee
0
 
LVL 5

Expert Comment

by:Peewee
Comment Utility
vasavi,

please clean up the status of this question?


regards Peewee
0
 

Expert Comment

by:SpideyMod
Comment Utility
Force Accepted

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now