Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Cookies Reading and Writing

zaszas Member Posts: 1
How I make a cookie:
print "Set-Cookie: NAME=$cid
";

This is how I read a cookie:
$cdata = $ENV{'HTTP_COOKIE'}; ($name,$cid) = split(/=/,$cdata);

How do I erase the cookie, or replace it?

Comments

  • SouldrinkerSouldrinker Member Posts: 143
    Just set the cookie again using the Set-Cookie Header... if you want to erase it - leave the value blank. I don't know for certain, but there could be also an argument to give the browser information on the "time to live" for this cookie, if it is so - set this on yesterday or some day in the past - then the cookie will be erased.


    best regards,

    sebastian mohrenstecher
    executive secretary
    net::allies

    www.net-allies.de
    [email protected]

  • JonathanJonathan Member Posts: 2,914
    Hi,

    Just to follow up this:-

    : I don't know for certain, but there could be also an argument
    : to give the browser information on the "time to live" for this
    : cookie,

    There is and it's the expires argument.

    print "Set-Cookie: NAME=$cid; expires=;
    ";

    Leave it blank like that (or not put it in at all) and the cookie lasts as long as the web browser is open. Close the web browser, it's gone. That's called a session cookie. If you put a date in there (the scalar output of a function like gmtime in Perl will probably do it well) then it'll expire on that date. Think max cookie life is 10 years??? But the user will probably chuck their computer on the rubbish heap before then....

    Hope all that's right!

    Jonathan

    -------------------------------------------
    Count your downloads:
    http://www.downloadcounter.com/
    And host your site:
    http://www.incrahost.com/
    Don't say I never give you anything... ;-)

  • Justin BibJustin Bib USAMember Posts: 0

    _______ // http://forcoder.org // free video tutorials and ebooks about \ Delphi Swift Visual Basic .NET Assembly C++ Java JavaScript Visual Basic PL/SQL Perl R Ruby Scratch PHP Go MATLAB Objective-C Python C# C Bash Ada Logo Alice Apex Scala FoxPro Hack Julia Lisp Rust ABAP Scheme Crystal LabVIEW Prolog Dart Awk D SAS ML Clojure Fortran Transact-SQL VBScript F# Kotlin COBOL Lua Erlang \ ______

Sign In or Register to comment.