How do I change the cookie name of a Hunchentoot session specializing in function?

I am using Hunchentoot and would like to change the session cookie name. This is implemented using a universal function, and as the docs say, you can “specialize a function” to change the name.

I'm not quite sure what that means. I got the impression that the specialization of the function is to send the method to certain types of arguments. In this particular case, the function accepts a server acceptor, and I do not want to change it. Can someone light me up on this?

API: http://weitz.de/hunchentoot/#session-cookie-name

Here's the implementation in the source:

(defgeneric session-cookie-name (acceptor) (:documentation "Returns the name \(a string) of the cookie \(or the GET parameter) which is used to store a session on the client side. The default is to use the string \"hunchentoot-session\", but you can specialize this function if you want another name.")) (defmethod session-cookie-name ((acceptor t)) "hunchentoot-session") 
+4
source share
1 answer

Create a subclass and specialize in this way:

 (defclass my-acceptor (hunchentoot:acceptor) ()) (defmethod session-cookie-name ((acceptor my-acceptor)) "my-session") 

The function still accepts an acceptor, it's just your acceptor, now.

+3
source

Source: https://habr.com/ru/post/1298955/


All Articles