Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.3.7rc3 does not pick up cookies #6252

Closed
pmeier opened this issue Jan 22, 2024 · 0 comments · Fixed by #6254
Closed

1.3.7rc3 does not pick up cookies #6252

pmeier opened this issue Jan 22, 2024 · 0 comments · Fixed by #6254

Comments

@pmeier
Copy link
Contributor

pmeier commented Jan 22, 2024

import panel as pn
import param


class AuthPage(pn.viewable.Viewer, param.Parameterized):
    js = param.String(default="")

    def __init__(self):
        super().__init__()
        self.cookies = pn.pane.HTML("")

    async def login(self, event):
        self.js = f"document.cookie = 'foo=bar';"

    @pn.depends("js")
    def run_js(self):
        return pn.pane.HTML(f"<script>{self.js}</script>")

    async def refresh_cookies(self, event):
        self.cookies.object = str(pn.state.cookies)

    def __panel__(self):
        return pn.Column(
            self.run_js,
            pn.widgets.Button(name="Login", on_click=self.login),
            pn.widgets.Button(name="Refresh cookies", on_click=self.refresh_cookies),
            self.cookies,
        )


auth_page = AuthPage()
auth_page.show()

Below are two screencasts with panel==1.3.6 and 1.3.7rc3 that perform the following steps:

  1. Run the script above.
  2. Check the document.cookie attribute in the browser console and make sure it is empty
  3. Press the "Login" button
  4. Check the document.cookie attribute again and make sure it is set to foo=bar
  5. Refresh the page to send the cookie to the panel application
  6. Click the "Refresh cookies" button to display the dictionary of available cookies
  7. Check the document.cookie attribute again and make sure it is set to foo=bar

1.3.6

1.3.6.webm

1.3.7rc3

1.3.7rc3.webm

Although the procedure is exactly the same, the cookie is not picked up by 1.3.7rc3 despite it being available in the browser console.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant