|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
cookie problem
Hi ,
im trying to execute a urlcounter-script through a index.shtml page via a ssi command (<!--#exec cgi="cgi-bin/in.cgi" -->), but the script cant set any new cookie, probably because that the header already has been set according to the shtml page , i tried to put the ssi command before the head in the shmtl page , but it didnt help ? Regards Adam ![]() |
|
#2
|
||||
|
||||
|
You can not pass cookies, via SSI scripts within a static page.
__________________
Thunder Rain Internet Publishing Custom Programming & Database development Providing Personal/Business Internet Solutions that work! |
|
#3
|
|||
|
|||
|
ok... but there must be some trix to do so ? obviesly some tradescript can read/write cookies within a html page, there a lot of link sites outthere which can set/read cookies, the question is how they could do that...
|
|
#4
|
||||
|
||||
|
Sure, there many ways to do this. Using PHP, creating and generating your pages dynamically with Perl and various modules.
Mickalo |
|
#5
|
|||
|
|||
|
In what way do u mean that i could use dynamically pages with perl to pass cookies?
|
|
#6
|
||||
|
||||
|
I use the CGI.pm module which is standard with Perl 5.03+. Here's a real simple example of passing a cookie with your content-type header:
Code:
use CGI qw(:standard); my $new_cookie = 'a_cookie_value_here'; $a_cookie=cookie(-name=>'cookie_name',-value=>"$new_cookie") # Now open some template or dynamice page open(TMPL,"<$some_template_file") || die $!; local $/; my $lines = <TMPL>; close (TMPL); # Pass the cookie here $a_cookie print header(-cookie=>"$a_cookie"); print $lines; exit; As I said, this a real simplified example, but I think you'll get the picture. There are many way to generate dynamically generated pages, mainly using the HTML::Templates is a excellent example and very easy to use. But this shows you how to pass a cookie when you are loading page. Hope this helps ![]() Mickalo |
|
#7
|
|||
|
|||
|
thanks ;-}
i guess that i have to read about templates... |
|
#8
|
|||
|
|||
|
Here is a long shot at this question........
Consider this Html page : <html> <head> <title>Fake SSI via picture to [ Javascript Cookie ??] test</title> <script language="Javascript"> function read_size(N){ alert(N); } </script> </head> <body> <p><img onClick="read_size(this.height);" src="images/box1.gif" width="50" height="50" border="0"></p> <p><img onClick="read_size(this.height);" src="http://YourSite.com/cgi-bin/image.cgi" border="0" alt="OOOps!"></p> </body> </html> And this image.cgi : #!c:/perl/bin/perl -w # CHANGE above line to match your perl location $gif_image = join ("/", $ENV{'DOCUMENT_ROOT'}, "images/button.gif"); if (open (IMAGE, "< $gif_image")) { $no_bytes = (stat($gif_image))[7]; binmode(STDOUT); # Required on windows binmode(IMAGE); # Required on windows print "Content-type: image/gif", "\n"; print "Content-length: $no_bytes", "\n\n"; print <IMAGE>; } else { print "Content-type: text/plain", "\n\n"; print "Sorry! I cannot open the file $gif_image!", "\n"; } exit (0); ############## You can get the image height after the image is sent via cgi. You could send back slightly different heights or widths of a clear image and use these to work out some sort of code. You can pass via GET variables back to the cgi : /image.cgi?Name=bob&OS=Mac and then act apoun the variables to send back the right image. You could then use Javascript to write a cookie on the client side. Hope this stirs the grey matter. It may be too off base for this question though.
__________________
Thanks Foot in Mouth ver 1.2.5 Onion |
|
#9
|
||||
|
||||
|
Hey footinmouth,
I like the idea, have you been reading about XLinks? Seems like a similar idea to me. I have never played with using the <IMG> tag to grab something back in this manner. Have you had success with it? I guess my only concern would be the potential for a web client to go nuts if the right things didn't appear in the returnec document simply because this was an image tab. Anyway, I think this is a question for another post. ![]() Robert. BTW, what use is a counter anyway? Is it for your benefit or the guy downloading the page?
__________________
Robert. |
|
#10
|
|||
|
|||
|
XLinks ???
[COMMERCIAL BREAK]
How is the weather in Manchester ? I have Family in LiverPool Area. [WoolyBacks] [/COMMERCIAL BREAK] Sorry I have not heard of XLinks .... Do You have a URL handy to look up this alien term ? woolybacks refers to the piece of England on the back of Wales. (=====: Thanks for the Link |
|
#11
|
||||
|
||||
|
Hi footinmouth,
[WEATHER FORECAST] It's actually quite nice here at the moment, a very warm evening, doors open, glass of wine all that... ![]() [/WEATHER FORECAST] Sorry, I should have posted the a URL. Try this for size. If you are interested in a book, I found the New Riders "XHTML" book an excellent reference point, in fact it is slowly converting me Happy reading - Robert. PS. Sorry, I don't know the WoolyBacks PPS. XHTML may make a sane HTML wizard gibber in the corner of a room until it begins to sink in! |
|
#12
|
|||
|
|||
|
On Subject [sometimes] or not
You could use the code I put there above but say with
six images calling a script: so : 1. src="http://YourSite.com/cgi-bin/image.cgi?digit=one" 2. src="http://YourSite.com/cgi-bin/image.cgi?digit=two" 3. src="http://YourSite.com/cgi-bin/image.cgi?digit=three" 4. src="http://YourSite.com/cgi-bin/image.cgi?digit=four" 5. src="http://YourSite.com/cgi-bin/image.cgi?digit=five" 6. src="http://YourSite.com/cgi-bin/image.cgi?digit=ten" and the script could send back after counting the hits some where the appropriate gifs [ 0-9 ].gif to fill in the images. Or could you send back a perl crafted single gif to show the counter digiits as one ?? Maybe : #!/usr/bin/perl -easy |
|
#13
|
|||
|
|||
|
image tag used in this method appears restricted
I have tried all sorts but the image tag used in this method
requires an valid image back from the cgi process . It can be a clear 1x1 pixel gif. Is this a Politically Correct Web Technique ??? On the Not so ' P.C.W.T. ' ------------------------------------------------------------------------- You could though [per browser] : Have javascript write out those image src's and pass client information to the cgi and just have the cgi return a "normal" picture. BUT: That might kinda be kin to a "secret type of session variable" depending on the information javascript appended in a GET format of the src cgi request. BIG Brother is watching you. As I said at the start this is a long shot, why not just be candid and open with people and use cookies or hidden variables or ?? but just be honest about the technology and the mulititude of browser software that must be supported. The end of the world will not come from honest communication for the purposes of tracking a shopping cart or preferences of a client. Or will it ? News at Ten film at Eleven.............. |
|
#14
|
|||
|
|||
|
hmmm...
but i dont get how u could read/set a cookie from a javascript if the cgi prg is executed from my index.html, then $ENV{HTTP_REFERER} probably will contain URL ... and u could not be sure about that a certain image will be clicked... or am i totaly lost ?? I talked to a guy who said that i could write the perl code inside html page if my Apache server was switched on to mod_perl , is that true? I tested with <_script language="perl"_> print "testing.."; <_/script_> (not underscore in the original version) but the ouput was blank... or is it another syntax? Regards Adam ![]() |
|
#15
|
|||
|
|||
|
No the page is static , only the image is fluid
I understand your confusion.
Client side JS cookies are just that Client side not server side. A static page that calls an image off a CGI program. -- this is a web developer vs the browser -- clients can turn on or off the site as they wish [or] Basically : Look at the code provided in the above message : The JS code and HTML code would be written in anticipation of the images called from this small cgi request. Crime Wise: Alien Forces on Mars have asked browser makers to allow this un-conventional practice as too many Farmers have seen their Kraft approach and abduct politicians. Just ask any one at serious Donut shop's if this is true or not. Up here in Kanada , slightly north of the USA , we all understand UFO's and perl is just another mystery. We all hope that the dewy Decimal system and the public Library all converge with Larry Wall to create fluid dynamic learning . Have a good Canada Day , July 1 , 2001 or Happy July 4 th for People in the USA I will have to venture South for a " Taco Bell " soon. See Ya .............. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > cookie problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |