Hi,

I want to build a feature into my site where people can pick out 5 of some 5000 favourite links to be displayed as the users favourite links across the site. I'm working on a perl script that will hopefully allow for this...

However, I wanted to expand on the usual format of the cookie I have. Ideallly a single cookie will hold the 5 values for each seperate id of the link.

The values would be one for each link and would consist of an id+4 digits which are picked off a query string. There is a .HTaccess file and XSSI code to deal with thr front end.

Link would be fired on the website by either:
<a href="/cgi-bin/setfavourite.pl?<!--#echo var="PAGE_ID" -->&addfavlink">Add <!--#echo var="label" --></a> for adding a one
&
<a href="/cgi-bin/setfavourite.pl?<!--#echo var="PAGE_ID" -->&removefavlink">Remove <!--#echo var="label" --></a> for removing a one.

Here is the PERL code I have so far:
#!/usr/local/bin/perl use CGI; $query = new CGI; my ($number, $fav1, $fav2, $fav3, $fav4, $fav5, $cookie); my $nextpage ='http://www.domain.co.uk/'; if (m/^(\d+)&addfavlink/) { $number = $1; $addfavlink = "id".$number; $cookie = $query -> cookie( -NAME => 'FAV5LINK', -VALUE => '$fav1', '$fav2', '$fav3 +', '$fav4', '$fav5', -EXPIRES => '+1y', -DOMAIN => '.domain', -PATH => '/', -SECURE => '0' ); print $query -> header( -COOKIE => $cookie, -LOCATION => $nextpage."userchoice.sht +ml?id=$number&added" ); } elsif (m/^(\d+)&removefavlink/) { $cookie = $query -> cookie( -name => 'FAV5LINK', -VALUE => '$fav1','$fav2','$f +av3','$fav4','$fav5', -EXPIRES => '-1h', -DOMAIN => '.domain, -PATH => '/', -SECURE => '0' ); print $query -> header( -COOKIE => $cookie, -LOCATION => $nextpage."removed.html" );<br /> } exit 0;

The content should define in the content area of the cookie the values *= omitted *(fav1=)id0008... etc ...etc

Ideally I wanted to allow for updating the cookies values to allow for replacing the 'fav1' with something else or the user adding a 'fav2'. Also there would only be a maxiumum of 5 values for this named cookie.

I got my head around it a little bit but am in much need of help.

many thanks, mat


In reply to CGI cookies: in much need of help by matc

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.