Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: CGI cookies: in much need of help

by EvdB (Deacon)
on Feb 12, 2004 at 15:38 UTC ( [id://328587]=note: print w/replies, xml ) Need Help??


in reply to CGI cookies: in much need of help

A few comments:
  • You never read in the value of the cookie you want to edit - so how do you know what other links have been saved.
  • The two cookies you create have different names - is this right?
  • One of your cookies is set to expire immediately (one hour ago).
  • Don't let Hutton get you down :-)

To acheive what you are after I would suggest:

get value off cookie do we want to add or remove link to cookie value add: add the link, trim if needed to 5 values remove: remove link save new cookie value && redirect to new page.

HTH.

Update: removed comment on html in code.

--tidiness is the memory loss of environmental mnemonics

Replies are listed 'Best First'.
Re: Re: CGI cookies: in much need of help
by matc (Initiate) on Feb 12, 2004 at 16:31 UTC
    Hi,

    lol - not exactly the most well formed code I have to admit. and as for the Hutton, I have better things to worry about than him... like my old dear for a start ;)

    ...
    names - should be the same for sure.

    The cookie set to -1h should really be '0' or nothing '' to end the session when the all browser instances are closed.

    once the cookie has been set with the first value and redirected to the desire id=....?added it should display the new link in a section of the site with a add remove text link next to any and all.

    The way I was think but need to ask if its right to do this...

    The only reason the user should call this script is to add and delete links. the actual printing of values will be embedded into the section of the page and will read the cookie from there. The reason for this is that some pages are static and some are dynamic, this script hopefully will just serve as the mechanism. To be honest I haven't got to that bit.

    The only thing the script should really do is update the cookie with the users values and like you said trim/limit them to a total of five values. there doesn't really have to be any user msg for when they reach the maxiumum of 5 links, I'll think about that later when I learn a bit more about PERL.

    Hope that anwsers some of the stuff anyway. so the routines should include what you mentioned.

    Add
    1. clock the named cookie and set a new one if need. Add the values(s) and limit to 5.

    Remove
    2. grab the name of the cookie and delete the selected value. and update the number of values.

    Seems you got me thinking now could I stick another value in the cookie that would hold the value count... a ha.. something like count .. that starts at 0 and goes to total 5. That would help the front end code know how many links are there and respond correctly hey!?

    peace, mat

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://328587]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-25 11:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found