@@ -158,10 +158,10 @@ export class Cookie<T> implements ElysiaCookie {
158158 set value ( value : T ) {
159159 // Check if value actually changed before creating entry in jar
160160 const current = this . cookie . value
161-
161+
162162 // Simple equality check
163163 if ( current === value ) return
164-
164+
165165 // For objects, do a deep equality check
166166 if (
167167 typeof current === 'object' &&
@@ -175,7 +175,7 @@ export class Cookie<T> implements ElysiaCookie {
175175 // If stringify fails, proceed with setting the value
176176 }
177177 }
178-
178+
179179 // Only create entry in jar if value actually changed
180180 if ( ! ( this . name in this . jar ) ) this . jar [ this . name ] = { ...this . initial }
181181 this . jar [ this . name ] . value = value
@@ -186,7 +186,11 @@ export class Cookie<T> implements ElysiaCookie {
186186 }
187187
188188 set expires ( expires : Date | undefined ) {
189- if ( this . cookie . expires === expires ) return
189+ // Handle undefined values and compare timestamps instead of Date objects
190+ const currentExpires = this . cookie . expires
191+ if ( currentExpires === undefined && expires === undefined ) return
192+ if ( currentExpires ?. getTime ( ) === expires ?. getTime ( ) ) return
193+
190194 if ( ! ( this . name in this . jar ) ) this . jar [ this . name ] = { ...this . initial }
191195 this . jar [ this . name ] . expires = expires
192196 }
@@ -245,7 +249,9 @@ export class Cookie<T> implements ElysiaCookie {
245249 return this . cookie . sameSite
246250 }
247251
248- set sameSite ( sameSite : true | false | 'lax' | 'strict' | 'none' | undefined ) {
252+ set sameSite (
253+ sameSite : true | false | 'lax' | 'strict' | 'none' | undefined
254+ ) {
249255 if ( this . cookie . sameSite === sameSite ) return
250256 if ( ! ( this . name in this . jar ) ) this . jar [ this . name ] = { ...this . initial }
251257 this . jar [ this . name ] . sameSite = sameSite
0 commit comments