?
Solved

Cookie problem

Posted on 2002-07-07
5
Medium Priority
?
164 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
[X]
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
  • 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 300 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

770 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