[ic] Cookies-Enabled Checking Routine

Mike Heins interchange-users@icdevgroup.org
Tue Jul 2 16:16:01 2002


Quoting G Guttero (gguttero@hotmail.com):
> >>Why is the cookies-enabled checking routine in the demo like this:
> >>
> >>	[calc]
> >>		my $cname = $Config->{CookieName} || 'MV_SESSION_ID';
> >>		$Scratch->{have_cookie} = $Tag->read_cookie($cname)
> >>			and delete $Scratch->{tried};
> >>		return;
> >>	[/calc]
> >>	[if scratch have_cookie]
> >>	[elsif scratch tried]
> >>     		You must have cookies set to leave the basket. Check out now or 
> >>forever
> >>     		lose your shopping cart.
> >>	[/elsif]
> >>	[else]
> >>		[set tried]1[/set]
> >>		[bounce href="[area ord/basket]"]
> >>	[/else]
> >>	[/if]
> >>
> >>Why isn't it simple like:
> >>
> >>[if type=explicit compare="q{[read-cookie MV_SESSION_ID]}"]
> >>[else]
> >>You must have cookies set to leave the basket. Check out now or forever 
> >>lose your shopping cart.
> >>[/else]
> >>[/if]
> >>
> >>What is the added benefit of the top one?
> >
> >It is compatible with any session id cookie name, for one. Most people
> >wouldn't change it, but you can name the cookie anything.
> >
> >In later IC versions, you could probably do:
> >
> >catalog.cfg:
> >
> >	AutoVariable  CookieName
> >
> >then
> >
> >[if type=explicit compare="q{[read-cookie __CookieName__]}"]
> >[else]
> >You must have cookies set to leave the basket. Check out now or >forever 
> >lose your shopping cart.
> >[/else]
> >[/if]
> >
> >But that requires setup changes, and the way it is works with any
> >configuration.
> 
> I totally understand what you're saying there.  But why bother with the 
> scratch variable "tried" and the bounce?  I just want to make sure I'm not 
> missing something.

Because if they are arriving via an external link, and have not had
a chance to return a cookie yet (it hasn't been set) then you don't
want to display the message.

-- 
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.513.523.7621      <mike@perusion.com>

People who want to share their religious views with you
almost never want you to share yours with them. -- Dave Barry