You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by "Andrew Stevens (JIRA)" <ji...@apache.org> on 2006/03/01 14:25:20 UTC

[jira] Commented: (COCOON-1592) Can't set cookie path etc. used by LocaleAction

    [ http://issues.apache.org/jira/browse/COCOON-1592?page=comments#action_12368279 ] 

Andrew Stevens commented on COCOON-1592:
----------------------------------------

For what it's worth, Vincent's patch passes the unit tests in COCOON-1779...


> Can't set cookie path etc. used by LocaleAction
> -----------------------------------------------
>
>          Key: COCOON-1592
>          URL: http://issues.apache.org/jira/browse/COCOON-1592
>      Project: Cocoon
>         Type: Bug
>   Components: * Cocoon Core
>     Versions: 2.1.7
>  Environment: Operating System: All
> Platform: All
>     Reporter: Andrew Stevens
>     Assignee: Cocoon Developers Team
>  Attachments: locale-cookie-settings
>
> I have a sitemap which can return pages in various languages, using the
> LocaleAction to determine which one to return for any given request.  I want to
> use <store-in-cookie>true</store-in-cookie> in the configuration of the
> LocaleAction.  However,
> org.apache.cocoon.i18n.I18nUtils.storeLocale(Map, String, String, boolean,
> boolean, boolean, boolean)
> uses
>             response.addCookie(response.createCookie(attribute, locale));
> and
> org.apache.cocoon.environment.http.HttpResponse.createCookie(String, String)
> simply does
>         return new HttpCookie(name, value);
> which means that although addCookie would set the the cookie domain/path/expiry
> to whatever is on the cookie it is passed, in practise the LocaleAction will
> always use the javax.servlet.http.Cookie defaults.
> My site has a reasonably deep page hierarchy.  Unfortunately, by default the
> cookies are only returned at or below the level of the page which set them.  So,
> if I request e.g
> /site/a?locale=en
> followed by
> /site/a/b?locale=zh_CN
> to switch the site to the Chinese version, I end up with two locale cookies
> stored for the site at different levels, and a subsequent request for
> /site/c
> returns the English version of the page instead of Chinese as was selected last
> :-(  In fact, if I select a different languages in several pages in various
> locations around the site, I can easily find myself browsing around and getting
> a different language on every page I visit!
> The other limitation, of course, is that the default MaxAge value is -1, forcing
> the browser to use a session cookie.  This means that if the user switches to a
> non-default (as determined by the Accept-Language header) language, then they'll
> have to do this again next time they come back to the site.  It would be nice to
> be able to specify e.g. a one month expiry on the cookie instead.
> I'm guessing this shouldn't be too difficult to add since
> o.a.c.environment.http.HttpCookie already contains setters for these other
> fields; just (!) some extra optional configuration parameters for LocaleAction
> to go with store-in-cookie, overload the storeLocale method in I18Utils to take
> the extra arguments and call the additional setters between the createCookie and
> addCookie calls...?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira