[wp-trac] [WordPress Trac] #35488: wp_logout() not working as it should

WordPress Trac noreply at wordpress.org
Sat Jun 19 15:45:35 UTC 2021


#35488: wp_logout() not working as it should
--------------------------------------+-----------------------------
 Reporter:  sebastian.pisula          |       Owner:  SergeyBiryukov
     Type:  defect (bug)              |      Status:  closed
 Priority:  normal                    |   Milestone:  5.3
Component:  Users                     |     Version:
 Severity:  normal                    |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+-----------------------------

Comment (by umut58tr):

 <?php
     /*
     Template Name:  RA_Cikis_Yap
     File:           RA_Cikis_Yap.php
     Site:           RanaAJANS.com
     User:           Rana ERDOĞAN & Ümüt DEMİR
     Date:           2020.04.20 20:20:20
     Page -> Page properties -> Template -> RA_Cikis_Yap.php
     */

     session_start();
     ob_start();
         $user_id = get_current_user_id();
     #    echo $user_id."<br>";
     #    echo "<pre>";
     #    var_dump(is_user_logged_in());
     #    echo "</pre>";
     wp_logout();
     session_unset();
     session_destroy();
     wp_destroy_current_session();
     wp_clear_auth_cookie();
     wp_set_current_user( 0 );
     update_user_meta( $user_id, 'session_tokens',
 mb_strtoupper(bin2hex(random_bytes(20))) ); # Generate random 40 character
 value
     //wp_redirect(site_url());

     header( "Refresh: 3; url= ".home_url()."/iletisim/" );
     // echo "<meta http-equiv='refresh' content='3;
 url=https://RanaAJANS.com/iletisim/'>";
     ?>

     <!doctype html>
     <html lang="tr">
     <head>
       <script
 src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
       <script
 src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js"></script>
     <style>
     .swal-overlay {
       background-color: rgba(250, 0, 0, 0.50);
     }
     .swal-modal {
       background-color: rgba(255,255,255,0.99);
       border: 3px solid white;
     }
     </style>
     </head>
     <body>
     <script>
       swal({
               type: 'error',
               icon: "warning",
               title: 'Oops...',
               text: 'Çıkış Yaptınız!',
               button: "Tamam",
               className: "swal-overlay",
               closeModal: false
             })
     </script>
     </body>
     </html>
     <?php
     ob_end_flush();
     exit();
     ?>

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/35488#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list