SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Jul 2009
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    a coding dought in session

    how to fix a timer in the session as like if the user didnt log out auto matically log out after a required time how to make it can ay body help me

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    The word is "doubt" okay?

    Second the timer doesn't go in the session's data. It has to go into a place that all sessions could access it. But there is no need for that anyways as PHP's garbage collection with remove old sessions.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    SitePoint Zealot
    Join Date
    Jul 2009
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no friend i have one site where how can fix a timer for the loging out like unfortunately the user didnt loged out means it should auto maticlly loged out after a few min so can we develope it through progrm wise can u help me if u can pls ok thnk for ur english

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    PHP's garbage collection will handle users who have not logged out. Just as I said previously.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #5
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Or do you mean logged out as in on a database?

    In which case you should have a field for 'last activity', rather than a 'logged in' field. Then, to see if they're logged in, see if their last activity is in the last $time seconds.

    For example:
    PHP Code:
    define('LOGGED_IN_LIMIT'60 60); //2 hours
    function isLoggedIn($Username){
        
    $Username MySQL_Real_Escape_String($Username);
        
    $Limit LOGGED_IN_LIMIT;
        
    $Query MySQL_Query("SELECT 1 FROM Users WHERE Username = '{$Username}' AND (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(LastActivity)) <= {$Limit}");
        return (
    MySQL_Num_Rows($Query) > 0);

    Not very sure with the date functions in MySQL, so there may be a better way... (enter Rudy...)
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •