Help regarding cookies !

Status
Not open for further replies.

DefecTalisman

Community Advocate
Community Support
Messages
4,148
Reaction score
5
Points
38
Ok, I can send and recieve cookies via the browser using perl.
The user can go to many different pages in that browser and then rutrn to my script and the cookie data remains. But when the browser is closed or the user uses another instance of a browser the cookie is no longer.

The question I am asking is how can I save the cookie to the users machine for a later date?

When looking up default location for cookies, I am faced with differnet ones for different browsers. Does this mean that I must check the users browser and then act accordingly?
Internet Explorer
%userprofile%\Cookies\
%userprofile%\Local Settings\Temporary Internet Files\

FireFox
%userprofile%\Application Data\Mozilla\Firefox\Profiles\Default User\cookies.txt

Opera 8
%userprofile%\Application Data\Opera\Opera\profile\cookies.dat

Netscape Navigator 7
%userprofile%\Application Data\Mozilla\Profiles\profile name\cookies.txt

If not is there not an easier way of saving them?

Any help or comment would not go amiss.

Regards,
 
Last edited:

DefecTalisman

Community Advocate
Community Support
Messages
4,148
Reaction score
5
Points
38
Set the cookie expiration time - this makes them persistent.

http://cs.hofstra.edu/~csckzp/csc290/perl-cookies.html#sec3
That should help.

No you don't need to treat cookies in different browsers differently (as far as I know).


Hmm... doh.

Had it set to +3y, rather than +2y.

Thank you for the info though...

So basically once that little bugger is on the users machine I can recognise them from there on in till they delete it(or 2years goes by)?
 

Corey

I Break Things
Staff member
Messages
34,551
Reaction score
204
Points
63
That should be correct, I'm not sure if there is a max default time that you can't surpass though.
 

DefecTalisman

Community Advocate
Community Support
Messages
4,148
Reaction score
5
Points
38
Ok... now I got the little bugger to stay.
Great.

Now is there a way using CGI::Cookie to check for a exsisting cookie and act on the response.

eg:

sub get_cookies {
%cookies = fetch CGI::Cookie;
if (%cookies eq undef) {
&make_cookies;
} else {
&set_cookies;
}
}

NB: the above doesn't work ? ? ?

sub get_cookies {
%cookies = fetch CGI::Cookie;
if ( ! %cookies ) {
&make_cookies;
}
$id = $cookies{'ID'}->value;
$log = $cookies{'LOG'}->value;
}

This also doesn't work ? ? ?

:lockd:I am really hitting dead ends here:lockd:

Ok, got it... Was being a real twit... So under my nose and I couldn't see it.

The source of the problem was I was creating 2 cookies, one had a expiry date and the other not, so it died on every close of the browser.

The checking for cookies was an incorrect send method...(dont ask what i was trying to do)

Ok, that is it from me for now(for a while I hope).
 
Last edited:
Status
Not open for further replies.
Top