hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : session managment
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

session managment

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 07-26-2005, 11:23 AM
michael-lane michael-lane is offline
Junior Guru
 
Join Date: Mar 2005
Posts: 211

session managment


i'm making a site blog for my site and i want to use sessions, probem is, i have a question if a user is on a page but stays on it for an hour i want the session to do something, i dont want him to be logged out completely but i want him to be logged out after hes inactive after a long time, but i want him to appear as logged off, to others if he is inactive for 5 mins or more. can someone tell me how i'd do this with php and mysql?

Reply With Quote


Sponsored Links
  #2  
Old 07-26-2005, 11:34 AM
maxymizer maxymizer is offline
Web Hosting Evangelist
 
Join Date: Apr 2005
Posts: 521
Create a system for tracking of users clicks. For each click your user makes, store a timestamp (fastest would be to another session, but I've seen most people are storing it to a database).

Taking in note that timestamp of last users activity, you can produce any calculation you need - when was the last time that user was active, how many minutes passed after his last click etc.

Reply With Quote
  #3  
Old 07-26-2005, 01:49 PM
michael-lane michael-lane is offline
Junior Guru
 
Join Date: Mar 2005
Posts: 211
Ok, i know that but lets say i was on this forum for like 5 hours inactive, would i be logged out?, would i appear offline but still be logged on? would i remain logged on forever like till next week, or would it log me out tommorow, would i appear offline till next week, all these questions confuse me.

Reply With Quote
Sponsored Links
  #4  
Old 07-26-2005, 02:07 PM
gilbert gilbert is offline
Web Hosting Master
 
Join Date: Jun 2003
Location: United States of America
Posts: 1,831
i think what maxymizer is trying to say is your last clicks time would keep you in a list if your last click was less than 5 minnutes old

a cookie on your computer would keep you logged into the forum itself or whatever you got going on

__________________
Play Flash Games | Upload Images

Reply With Quote
  #5  
Old 07-26-2005, 02:40 PM
adaml adaml is offline
Web Hosting Guru
 
Join Date: Oct 2002
Location: York, United Kingdom
Posts: 260
Just set a session time out?!?! You can set this in your php.ini file or using a .htaccess file.

You can find more infomation here :

http://uk.php.net/manual/en/ref.session.php


For a site i have built the user isnt allowed to stay logged in for more than 1 hour then they must relogin. So on every click it checks the session and checks the current time then works out how far long its been. If:

time logged in > 1 hour ---> Destroy session.

__________________
adamlivesley
http://84degrees.com

Reply With Quote
  #6  
Old 07-26-2005, 06:38 PM
michael-lane michael-lane is offline
Junior Guru
 
Join Date: Mar 2005
Posts: 211
no you dont get it earlier i was on the forum for 4 hours, yet when i came back i was still classed as signed in.

Reply With Quote
  #7  
Old 07-26-2005, 06:49 PM
adaml adaml is offline
Web Hosting Guru
 
Join Date: Oct 2002
Location: York, United Kingdom
Posts: 260
ohh So you want to keep people signed in ?

If you didnt close the browser its a session that never expirys enless you close the browser. Or its like WHT and uses Cookies so it remembers you

__________________
adamlivesley
http://84degrees.com

Reply With Quote
  #8  
Old 07-26-2005, 06:53 PM
michael-lane michael-lane is offline
Junior Guru
 
Join Date: Mar 2005
Posts: 211
No, you all dont understand, i dont want users to sign in every few seconds but i dont want them to leave and then come back to find themselves still logged in cause the session never expired. Yet i dont want a user to go out for an hour come back and find that they've been logged out.

Reply With Quote
  #9  
Old 07-26-2005, 07:08 PM
arkin arkin is offline
Web Hosting Guru
 
Join Date: Feb 2003
Location: L.A. C.A.
Posts: 334
Dude, simply record the time of there last action in the session.

$_SESSION['lastact']=time();

Then simply compare it with a mktime of say -5 hours and if its more than 5 hours, session_destroy?

Do you understand or do you want code examples, I'm extremely tired so I would have to write in the morning.

Reply With Quote
  #10  
Old 07-26-2005, 07:24 PM
michael-lane michael-lane is offline
Junior Guru
 
Join Date: Mar 2005
Posts: 211
i'm not iusing $_SESSIONs i'm using database sessions like phpbb does.

Reply With Quote
  #11  
Old 07-26-2005, 07:37 PM
michael-lane michael-lane is offline
Junior Guru
 
Join Date: Mar 2005
Posts: 211
i'm not iusing $_SESSIONs i'm using database sessions like phpbb does.

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Desktop Hosting: High-Margin Opportunity for a New Cloud Service – WPC 2012 Web Hosting News 2012-07-11 14:57:43
Learn How to Scale Your Business - Join Us In Wednesday’s Webinar Blog 2011-12-06 20:29:17
Attend Today’s Cloud Security Webinar with Dome9 Blog 2011-10-11 14:54:27
Join Tomorrow’s Webinar on OpenStack and Dell’s Crowbar Blog 2011-08-24 22:12:52
Check out Last Week’s Excellent Webinar with Endurance and Litle in the Archive Blog 2011-06-03 20:52:18


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?