From: Jeff D. <da...@da...> - 2002-09-30 15:30:42
|
I haven't tried the plugin yet, but here's my one coding suggestion. You can use $request->setSessionVar() and $request->getSessionVar() to save persistent data. (Also $request->{get,set}CookieVar...) And you can save arrays (or anything else) that way. So instead of > $Page=array(); > // Shift down the page names and store them back to cookies > for ($count=$numberlinks; $count>0; $count--) { > $thisvalue="PageTrail".$count; > $thiscookie = @$_COOKIE["$thisvalue"]; > if ($thiscookie!="") { > $Page[$count+1]=$thiscookie; > } else { > $Page[$count+1]=""; > } > } > $Page[1]=$thispage; > // Now lets cycle through them saving them with setcookie > $html = " "; > for ($count=$numberlinks; $count>0; $count--) { > if ($Page[$count]!="") { > $Name="PageTrail" . $count; > $Value = $Page[$count]; > setcookie ($Name, $Value, 0, '/'); > } > } You can do something like (this is untested, of course, so guaranteed not to work): $pagetrail = $request->getSessionVar('PageTrail'); if (!is_array($pagetrail)) // FIXME: probably better validation is in order... $pagetrail = array(); array_unshift($pagetrail, $thispage); array_split($pagetrail, $numberlinks); // limit trail length $request->setSessionVar('PageTrail', $pagetrail); (Note that $pagetrail is a zero-based array, rather than a one-based array...) Besides being cleaner code, it has the advantage of not storing a whole handful of cookies in the clients browser... Cheers! |