Solved

Cookie problem

Posted on 2002-07-07
5
162 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 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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

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…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
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…

696 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