Hi,

I am writing a prgram in php.when i click "log out "button ,it redirects to my first page "index.php".(username & password)

and then by clicking back button in the browser ,it showing all my previous pages that i visited.

I want to disable back button in the browser (javascript should support in all browser) using javascript or php

santhanalakshmi

Try to create function that prevent's right click or some function to be trigger on unload event.

The simplest answer to your question is, No. Its not possible to disable 'back' button of the browser.
As far your question is concerned, When the user logs in, you can set a session variable, say, $_SESSION['validuser'] = true; And on every page, check if $_SESSION is true. If its empty or anything but true, redirect him to the login page. When the user clicks logout button, unset the session.

The simplest answer to your question is, No. Its not possible to disable 'back' button of the browser.
As far your question is concerned, When the user logs in, you can set a session variable, say, $_SESSION['validuser'] = true; And on every page, check if $_SESSION is true. If its empty or anything but true, redirect him to the login page. When the user clicks logout button, unset the session.

yeah i agree, your problem is authorization problem, not back button. if the users log out then they will become unauthorized so they can not view their pages.

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.