Hi

I want to clear back button history in browser after log out in php

Thanks in advance

Recommended Answers

All 4 Replies

Member Avatar for diafol

I don't think that's possible. I'd be furious if a website could take control of my browser and delete stuff.

It won't be possible in PHP anyway, because it runs on the server, and not in the browser.

Member Avatar for diafol

What is your specific problem? sessions not clearing data on logout?

In the logout script, use unset(name_of_session_variable) to invalidate session. Plus, in all pages, before displaying the output, use an if condition and check if the session variable exists.

Example: in logout script,

unset ( $_SESSION ['name'] );

In all other pages, 
    if(isset($_SESSION['name']))
    {
        //display data
        echo "success";
    }
    else
    {
        //redirect to homepage/index page
        header('Location: /index.php');
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.