Skip to content

Commit c41c8ba

Browse files
committed
remove session if user is not logged in and close session
1 parent 8b9bdec commit c41c8ba

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tawkto/tawkto.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -624,12 +624,17 @@ public function start_session() {
624624
return;
625625
}
626626

627-
if ( ! is_user_logged_in() ) {
628-
return;
629-
}
630-
631627
if ( session_status() === PHP_SESSION_NONE ) {
632628
session_start();
629+
630+
// If user is not logged in, remove the visitor session and close the session.
631+
// Session cannot be updated if it is not started.
632+
if ( ! is_user_logged_in() ) {
633+
if ( isset( $_SESSION[ self::TAWK_VISITOR_SESSION ] ) ) {
634+
unset( $_SESSION[ self::TAWK_VISITOR_SESSION ] );
635+
}
636+
session_write_close();
637+
}
633638
}
634639
}
635640

0 commit comments

Comments
 (0)