Skip to content
PHP Logo

What potential issues can arise when trying to end a session in PHP within a frameset?

When trying to end a session in PHP within a frameset, the session may not be properly destroyed due to the frameset structure. To solve this issue, you can add a script in the parent frame that explicitly destroys the session when the user logs out.

php
// Parent frame PHP code
session_start();

if(isset($_GET['logout'])) {
    session_destroy();
    header("Location: index.php"); // Redirect to the login page after destroying the session
    exit();
}
```

In the parent frame HTML file, add a logout link that calls the script in the parent frame:

```html
<a href="index.php?logout=true" target="_top">Logout</a>