Open Closed

Clear Local Storage after logout #8295


User avatar
0
nabass created

hi where can i find logout logic to clear database for example i added an item to my table this item store in local storage i want when logout and login again with same user to clear this local storage so how can i did it ? i attached simple video to see what i want to do thank you

https://streamable.com/4l44ba

  • ABP Framework version: v8.0.2
  • UI Type: Angular
  • Database System: EF Core (SQL Server)
Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

8 Answer(s)
  • User Avatar
    0
    Anjali_Musmade created
    Support Team Member

    Hello ,

    When the logout event is triggered, use JavaScript's localStorage.clear() method to remove all items from the local storage. Please try this once.

    Thank you.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    nabass created

    hi i already know localStorage.clear() what i want is (where) to write it in abp angular ? where logout event is triggered ??

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    nabass created

    i'm using abp angular so it handles the login page automatically so how can i access logout event ?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Anjali_Musmade created
    Support Team Member

    Hello ,

    Please try to this code in app.component.ts file. eg:-

    import { Component } from '@angular/core';
    import { OAuthService } from 'angular-oauth2-oidc';
    import { filter } from 'rxjs';
    
    @Component({
      selector: 'app-root',
    })
    export class AppComponent {
      constructor(private oAuthService: OAuthService) {
        this.oAuthService.events
          .pipe(filter((event) => event?.type === 'logout'))
          .subscribe((event) => {
            // logout event fired
            localStorage.clear();
          });
      }
    }
    

    When i click on logut button debugger was hit

    Thank you,

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    nabass created

    wow it works big thanks for you but routing disappear why ?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    nabass created

    i solved it thank you

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Anjali_Musmade created
    Support Team Member

    Hello,

    At my side its work there is nothing any issue check here.

    You can refer this document https://abp.io/docs/8.2/tutorials/book-store/part-02?UI=NG&DB=EF if it is helpful for you.

    Thank you.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Anjali_Musmade created
    Support Team Member

    i solved it thank you

    Great : )

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 28, 2026, 11:44
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.