Code:
on *:CONNECT:{
  ;; network specific
  set $+(%, $network, ., somevar) example

  ;; connection specific
  set $+(%, $cid, ., somvar) example2
}
on *:DISCONNECT:{
  ;; unset network specific variables
  unset $+(%, $network, ., *)

  ;; unset connection specific variables
  unset $+(%, $cid, ., *)
}


to access the value of said variables
Code:
;; network specific
$($+(%, $network, ., somevar), 2)

;; connection specific
$($+(%, $network, ., somvar), 2)