I am working on a php project in codeigniter. When a user logs out, he/she is directed to login page. But when he/she clicks the back button of browser, he/she gets to see the home page just before the log out, which definitely not a good thing. I have added session check on every page so that when a user reloads any page after logout he/she will be directed to login page. As far as i think, this happens due to web browser using cache for the back button.So one solution as given in many stack overflow forums and others is to clear the cache, which i too did. But another problem came that the document expires after back button, which is not good from the UX point of view. Another solution is to add javascript code to restrict the page to itself when pressing back button, which surely works. But since the javascript is client side, this won't work if you disable it from browser. If you check the Gmail or facebook or any good site ,they handle it really well and no ,it's not by just javascript code , as suggested in this forum How Google deals with the Back Button after logout? , So my question is how do they handle it in real?
How Facebook and Google handles the back button after logout?
830 views Asked by Aniket Pandey At
2
There are 2 answers
3
Sankar Smith
On
One time I got that problem and finally I got many tiny solutions for that.
Put noscript tag in common header file. I return a text when the JS turn off.
<noscript>Your browser does not support JavaScript!</noscript>
Another Method to check the user logged or not at every intervel
setInterval(function(){
$("#autorefresh").load("checklogin.php?screenName=autorefresh");
}, 5000);
And finally put this back prevent js history.pushState(null, null, 'loginController.php?time=
$currentDateTime; ?>');
window.addEventListener('popstate', function(event) {
history.pushState(null, null, 'loginController.php?time=<?php echo $currentDateTime; ?>');
});
This is my experience knowledge... Thank You
Related Questions in JAVASCRIPT
- Using Puppeteer to scrape a public API only when the data changes
- inline SVG text (js)
- An array of images and a for loop display the buttons. How to assign each button to open its own block by name?
- Storing the preferred font-size in localStorage
- Simple movie API request not showing up in the console log
- Authenticate Flask rest API
- Deploying sveltekit app with gunjs on vercel throws cannot find module './lib/text-encoding'
- How to request administrator rights?
- mp4 embedded videos within github pages website not loading
- Scrimba tutorial was working, suddenly stopped even trying the default
- In Datatables, start value resets to 0, when column sorting
- How do I link two models in mongoose?
- parameter values only being sent to certain columns in google sheet?
- Run main several times of wasm in browser
- Variable inside a Variable, not updating
Related Questions in PHP
- How to add the dynamic new rows from my registration form in my database?
- Issue in payment form gateway
- How to create a facet for WP gridbuilder that displays both parent and child custom fields?
- Function in anonymous Laravel Blade component
- How to change woocomerce or full wordpress currency with value from USD to AUD
- General questions about creating a custom theme Moodle CMS
- How to add logging to an abstract class in php
- error 500 on IIS FastCGI but no clue despite multiple error loggings activated
- Composer installation fails and reverts ./composer.json and ./composer.lock to original content
- How to isolate PHP apps from each other on a local machine(Windows or Linux)?
- Laravel: Using belongsToMany relationship with MongoDB
- window.location.href redirects but is causing problems on the webpage
- Key provided is shorter than 256 bits, only 64 bits provided
- Laravel's whereBetween method not working with two timestamps
- Implementing UUID as primary key in Laravel intermediate table
Related Questions in FACEBOOK
- Facebook Post Images from local system on own Page
- Provide an archipelago name that humans cannot utter
- How can I look this email address
- Not getting all leads from Meta/Facebook using webhook for page leadgens
- Unsupported post request when trying to create a custom audience via the endpoint https://graph.facebook.com/lapi-version), (custom-audience-id/users)
- Java resized JPEG seems to be invalid format for Facebook?
- How to implement facebook pixel in flutter in 2024 any example?
- Need WhatsApp Data Backup from Api
- Facebook login via JS-SDK via OAuth will get stuck half-way
- Short time token with the Graph API and Facebook login through the iOS SDK
- Facing the "Messaging may be unavailable" error - WhatsApp Cloud API
- Facebook Graph API - Story endpoint does not return all active stories
- Javascript / Dynamically append text element above embedded facebook posts
- When I post text with media on Facebook, the text does not show
- How to search a list of groups using facebook APIs
Related Questions in BACK
- Flutter PopScope is not working whlie using popUntil
- Back to main menu button
- How can I listen to the toolbar back press event on a multiple base node setup navigation?
- Angular browser back button
- How to back transform the log transformed obtained BLUEs and BLUPs for linear mixed model in R?
- ASPX Drop Down List Selection incorrect select after clicking the BACK button
- what wrong on scroll top functionality
- Angular npm start with node servers
- Flutter Auto Router package with back swap gesture
- Browser back button using Nextjs refresh the component after a few seconds
- Monitor or review path when debugging in VS Code
- SQLiteDatabase Auto backup and restore
- Exlude files when I backup linux tar
- correct way to handle back event for the updated list in react native
- FlutterFlow iOS swipe to get back gesture throws an error
Related Questions in USER-EXPERIENCE
- Should we auto-scroll on sending/receiving a new message in a chat based interface?
- How can i apply a gradient color to a CurvedNavigationBar in flutter?
- Re-creating Forest App's UI (Forest element) in Flutter
- Handling selected item in a list with pagination on autoupdating the list in a react app ui
- How do i change the look of a tabitem? Literally Nothing happens no matter what i add to it
- How to get keyboard Cursor global position in jetPack Compose?
- How to create car start/stop button in flutter?
- How to sort order multiple columns using antd Table?
- Android Studio: How to keep logcat pinned when running the app?
- Performance and poor experience on element rotation with Angular
- I would like to set AnimatedOpacity to only a part, but it will only be reflected in the terminal child widget
- I want to mimic gradient colors, is there a tool or software that can help me figure out which colors I am creating and how?
- How to create a map of a country that allows me to select its states and take that input
- How i can manage cache in Next.js project with SSG pages, to improve user experience?
- How implement an alternative option when value is not in picker
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
On home page, you'll need to check if SESSION is active. When user is logging out, you'll need to destroy SESSION.
For example: -On Home Page
On logout page:
Hope this helps.