web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Using cookies in react...
Power Apps
Unanswered

Using cookies in react pcf components

(1) ShareShare
ReportReport
Posted on by 4
Has anyone been able to use localstorage or cookies successfully? I've done both up to the point where they work in the authoring portal, but they magically do nothing when in the published play version of the app
I have the same question (0)
  • Suggested answer
    kalluu91 Profile Picture
    39 on at
    Actually, the localstorage or cookies is related to the browser. It has nothing to do with the pcf component framework.
     
    I usually implement this class for managing the session storage (local storage will be the same):
     
    export function get<T>(key: string): T | undefined {  
      const value = sessionStorage.getItem(key);
      return value ? (JSON.parse(value) as T) : undefined;
    }
     
    export function set(key: string, value: any) {
      sessionStorage.setItem(key, JSON.stringify(value ?? {}));
    }
     
    Cheers,
    Kim Anh

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard