Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Cookie problem

Posted on 2002-07-07
5
159 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
ID: 7137370
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
ID: 7137376
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
ID: 7159186
vasavi,
did u get the answer you were looking for?

regards Peewee
0
 
LVL 5

Expert Comment

by:Peewee
ID: 7596397
vasavi,

please clean up the status of this question?


regards Peewee
0
 

Expert Comment

by:SpideyMod
ID: 8293081
Force Accepted

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this tutorial I will aim to show you how simple is making a small application in WhizBase, how to add, remove and update data in the DB. I will make a small address book application where you can add, browse, update and remove addresses. I wi…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

856 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