473,800 Members | 2,586 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

session destroy for while user stay in one page without any action

oranoos3000
107 New Member
hi
I 'd like to session destroy when that user for 1 hours dont dont press any key or scroll page and dont go to another or in other words stay in one page for a alot of time


thanks alot
Jun 6 '10 #1
1 2041
Atli
5,058 Recognized Expert Expert
Hey.

If you want to detect when a user presses a key or scrolls the page, and destroy a session based on that, you will need to use JavaScript and AJAX to trigger the PHP code that actually destroys it.

To do what you are asking, I would do the following:
  • Set PHP up so that the session times out after an hour. See this article for details on how to do that.
  • Create a PHP ping page that simply "refreshes" the session timeout. It wouldn't have to do anything other than start the session and update whichever timeout method you use (if any).
  • Have the JavaScript code monitor the user input. When the user is active, send periodic AJAX requests to the PHP ping page. If he becomes inactive, stop sending the AJAX requests.
The result of this would be that while the user is actively working on a page of your site, his session would remain alive, even though he never really requests anything from the server.
Jun 7 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2292
by: David Young | last post by:
I normally work on WinForms projects, but have been recently thrust into this arena and had a questions concering access to objects stored in session. We've apparently got an object (custom class) that's stored in session for each user of our app. This object provides information related to the use and their environment, as well as default data used in the system. One of these items is a reference to the stylesheet used for that user....
1
2857
by: twscott | last post by:
I will be posting information to another application from my applicatio and redirecting to that application which will load into anothe iteration of IE. The user may spend a significant amount of tim working in that application. I need to keep my session alive whil there is activity in the other application as that application will b sending me return data when its processing is complete. Is there a wa to keep my session active while the...
6
1279
by: Alan Silver | last post by:
Hello, I have a page where users can alter the contents of a shopping basket. Once they are happy with the contents, they click a "checkout" button and are taken to the checkout page. What actually happens is that the "checkout" button causes a normal postback, where some work is done before redirecting them to the checkout page. I need to pass the basket ID to the checkout page, but don't want to put it in the querystring as I don't...
4
9461
by: UJ | last post by:
I have a page where the user can upload a video file. As you can guess, this may take a while. Is there a way I can change the session timeout for just this one page? I would also want to change the forms authentication to be a large value for that page also. TIA - Jeff.
1
1661
by: Owen Richardson | last post by:
I have an asp.net website where i have a quick search facility built into my master page. the search is a web control, with a drop down country box and a list box full of cities. When i select my country my citylist is refreshed ok. I want to be able to then click on my city and jump to a specific page without loosing state; and i dont know how. Currently My change event on my city listbox does a...
4
3747
by: Nick Gilbert | last post by:
Hi, Is it possible to access the Session of an arbitary user from an aspx page? On an e-commerce site, I am notified of payment success via a callback from the payment server to an ASPX page on my system. I would like to be able to access the session of the user that submitted the order, and clear their basket. I don't really want to store their session in the database just to facilitate this.
4
4345
by: Sam | last post by:
I have an asp.net 2.0 app that uses a sitemap, Master Page, and has several content pages. While this feature has simplified the process of creating a data-driven site menu, it does seem to have some big restrictions. Namely, maintaining state on the Master Page across all content pages. I simply want to keep track of a key value across all content pages. The only solution I can come up with is using a session variable, which I hate.
38
5080
by: ted | last post by:
I have an old link that was widely distributed. I would now like to put a link on that old page that will go to a new page without displaying anything.
5
17307
by: Steve D | last post by:
I am not sure where to post this as it probably a combination of client and server script I am looking for. Basically I am trying to find out how to destroy a PHP session when the user navigates away from my site. Any help would be appreciated
3
13929
by: T. Wintershoven | last post by:
Hi all, After a visitor has loged in, a session is started. The session is destroyed after the visitor clicked "Log out'. When the visitor forgets to log out and closes the browser immediately, the session stil exists because when the visitor opens the browser again and comes back to the site he/she is still loged in. Ofcourse i don't want that. I want the session to be destroyed when the visitor closes the browser
0
9691
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10507
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10279
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10255
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10036
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9092
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7582
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4150
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.