Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 27th, 2001, 09:25 AM
startrader startrader is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Posts: 0 startrader User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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


Reply With Quote
  #2  
Old June 27th, 2001, 11:15 AM
mickalo's Avatar
mickalo mickalo is offline
Ole` Timer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Location: N.W. Iowa
Posts: 469 mickalo User rank is Private First Class (20 - 50 Reputation Level)mickalo User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 5 h 19 sec
Reputation Power: 8
Send a message via AIM to mickalo Send a message via MSN to mickalo
Thumbs up

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!

Reply With Quote
  #3  
Old June 27th, 2001, 02:48 PM
startrader startrader is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Posts: 0 startrader User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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...

Reply With Quote
  #4  
Old June 27th, 2001, 03:05 PM
mickalo's Avatar
mickalo mickalo is offline
Ole` Timer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Location: N.W. Iowa
Posts: 469 mickalo User rank is Private First Class (20 - 50 Reputation Level)mickalo User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 5 h 19 sec
Reputation Power: 8
Send a message via AIM to mickalo Send a message via MSN to mickalo
Thumbs up

Sure, there many ways to do this. Using PHP, creating and generating your pages dynamically with Perl and various modules.

Mickalo

Reply With Quote
  #5  
Old June 27th, 2001, 03:23 PM
startrader startrader is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Posts: 0 startrader User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
In what way do u mean that i could use dynamically pages with perl to pass cookies?

Reply With Quote
  #6  
Old June 27th, 2001, 03:39 PM
mickalo's Avatar
mickalo mickalo is offline
Ole` Timer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Location: N.W. Iowa
Posts: 469 mickalo User rank is Private First Class (20 - 50 Reputation Level)mickalo User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 5 h 19 sec
Reputation Power: 8
Send a message via AIM to mickalo Send a message via MSN to mickalo
Thumbs up

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

Reply With Quote
  #7  
Old June 27th, 2001, 05:59 PM
startrader startrader is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Posts: 0 startrader User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks ;-}

i guess that i have to read about templates...

Reply With Quote
  #8  
Old June 29th, 2001, 01:38 PM
footinmouth footinmouth is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: North Vancouver, BC, Canada
Posts: 44 footinmouth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Smile Hmmmmm.....

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

Reply With Quote
  #9  
Old June 29th, 2001, 02:39 PM
robert.swift's Avatar
robert.swift robert.swift is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Manchester, UK
Posts: 80 robert.swift User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
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.

Reply With Quote
  #10  
Old June 29th, 2001, 02:46 PM
footinmouth footinmouth is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: North Vancouver, BC, Canada
Posts: 44 footinmouth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
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

Reply With Quote
  #11  
Old June 29th, 2001, 02:57 PM
robert.swift's Avatar
robert.swift robert.swift is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Manchester, UK
Posts: 80 robert.swift User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
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!

Reply With Quote
  #12  
Old June 29th, 2001, 06:54 PM
footinmouth footinmouth is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: North Vancouver, BC, Canada
Posts: 44 footinmouth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
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

Reply With Quote
  #13  
Old June 29th, 2001, 08:00 PM
footinmouth footinmouth is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: North Vancouver, BC, Canada
Posts: 44 footinmouth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
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..............

Reply With Quote
  #14  
Old June 29th, 2001, 08:27 PM
startrader startrader is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Posts: 0 startrader User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #15  
Old June 29th, 2001, 10:28 PM
footinmouth footinmouth is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: North Vancouver, BC, Canada
Posts: 44 footinmouth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
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 ..............

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > cookie problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Linear Mode Linear Mode
Threaded Mode <