[ 
https://issues.apache.org/jira/browse/TAP5-1858?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13227462#comment-13227462
 ] 

Michael Wyraz commented on TAP5-1858:
-------------------------------------

Patch for 5.3 Branch:


### Eclipse Workspace Patch 1.0
#P tapestry5-trunk
Index: 
tapestry-core/src/main/java/org/apache/tapestry5/internal/services/CookiesImpl.java
===================================================================
--- 
tapestry-core/src/main/java/org/apache/tapestry5/internal/services/CookiesImpl.java
 (revision 1299621)
+++ 
tapestry-core/src/main/java/org/apache/tapestry5/internal/services/CookiesImpl.java
 (working copy)
@@ -121,7 +121,20 @@
 
         cookieSink.addCookie(cookie);
     }
+    
+    public void writeCookieValue(String name, String value, String path, 
String domain, int maxAge)
+    {
+        Cookie cookie = new Cookie(name, value);
+        if (path==null) cookie.setPath(request.getContextPath() + "/");
+        else cookie.setPath(path);
+        if (domain!=null) cookie.setDomain(domain);
+        if (maxAge!=0) cookie.setMaxAge(maxAge);
+        else cookie.setMaxAge(defaultMaxAge);
+        cookie.setSecure(request.isSecure());
 
+        cookieSink.addCookie(cookie);
+    }
+
     public void removeCookieValue(String name)
     {
         Cookie cookie = new Cookie(name, null);
Index: tapestry-core/src/main/java/org/apache/tapestry5/services/Cookies.java
===================================================================
--- tapestry-core/src/main/java/org/apache/tapestry5/services/Cookies.java      
(revision 1299621)
+++ tapestry-core/src/main/java/org/apache/tapestry5/services/Cookies.java      
(working copy)
@@ -67,6 +67,11 @@
     void writeCookieValue(String name, String value, String path, String 
domain);
 
     /**
+     * As with {@link #writeCookieValue(String, String, String)} but an 
explicit domain,path and maximum age may be set.
+     */
+    void writeCookieValue(String name, String value, String path, String 
domain, int maxAge);
+    
+    /**
      * Removes a previously written cookie, by writing a new cookie with a 
maxAge of 0.
      */
     void removeCookieValue(String name);

                
> Cookie service should allow to set path, domain AND maxAge
> ----------------------------------------------------------
>
>                 Key: TAP5-1858
>                 URL: https://issues.apache.org/jira/browse/TAP5-1858
>             Project: Tapestry 5
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.3.2
>            Reporter: Michael Wyraz
>
> Cookie service should allow to set path, domain AND maxAge with one method. 
> Currently there is one method for setting the path, another for cookies with 
> maxAge but none for cookies with maxAge+path.
> There should be a method like this:
>     void writeDomainCookieValue(String name, String value, String path, 
> String domain, int maxAge)
>     {
>         Cookie cookie = new Cookie(name, value);
>         if (path==null) cookie.setPath(request.getContextPath() + "/");
>         else cookie.setPath(path);
>         if (domain!=null) cookie.setDomain(domain);
>         if (maxAge!=0) cookie.setMaxAge(maxAge);
>         else cookie.setMaxAge(defaultMaxAge);
>         cookie.setSecure(request.isSecure());
>         cookieSink.addCookie(cookie);
>     }
> Each other method should call this one.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to