in reply to Base64 Encoded cookie is giving me headaches!
The first 8 bytes are probably the two dates, perhaps packed seconds since epoch. unpack those and convert them to dates with localtime. The remaining data is null-separated; split /\0/ to get the remaining fields. The last one does appear to be an MD5 hash, as you said.
Update: How about a code example? :)
#!/usr/local/bin/perl -w use strict; use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); use MIME::Base64; use CGI::Cookie; my $query = new CGI; my %cookies = fetch CGI::Cookie; my $cookie = $cookies{'Cookie-Name'}->value; print $query->header; print $query->start_html; print "<h1>Cookie</h1><br>\n"; print "Straight cookie: $cookie\n<br><br>\n"; my $decoded = decode_base64($cookie); my($time1, $time2) = unpack 'NN', $decoded; substr($decoded, 0, 8) = ''; print join "<BR>", "Decoded cookie:", scalar(localtime $time1), scalar(localtime $time2), split /\0/, $decoded; print $query->end_html;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Base64 Encoded cookie is giving me headaches!
by tame1 (Pilgrim) on Mar 17, 2001 at 01:40 UTC | |
by chipmunk (Parson) on Mar 17, 2001 at 02:19 UTC |