File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed
Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,31 @@ public static function set($key, $value = null)
101101 $ _SESSION = Anchor::deepSetDot ($ _SESSION , $ key , $ value );
102102 }
103103
104+ /**
105+ * Append to data in session
106+ *
107+ * @param mixed $key The session variable key
108+ * @param mixed $value The session variable value
109+ *
110+ * @return void
111+ */
112+ public static function append ($ key , $ value = null )
113+ {
114+ static ::start ();
115+
116+ $ data = static ::get ($ key );
117+
118+ if (!$ data ) {
119+ $ data = $ value ;
120+ } elseif (\is_array ($ data )) {
121+ $ data [] = $ value ;
122+ } else {
123+ $ data .= $ value ;
124+ }
125+
126+ $ _SESSION = Anchor::deepSetDot ($ _SESSION , $ key , $ data );
127+ }
128+
104129 /**
105130 * Remove a session variable
106131 */
@@ -259,4 +284,4 @@ public static function has($key)
259284 {
260285 return static ::get ($ key ) !== null ;
261286 }
262- };
287+ }
You can’t perform that action at this time.
0 commit comments