Session expiration help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Session expiration help

    Please i want you guys to help me with session.
    I want member session to expire if a member is idle for 10 minutes, but if not idle session should continue.
    This my ses from logme.php
    code:
    $user=$_GET['user'];
    $_SESSION['ses']=$user
    $timeout=time()+7200;
    $_SESSION['sesexpire']=$timeout;
    then my home.php
    $user=$_SESSION['ses'];
    if(!isset($user))
    {
    echo "you are not login or you idle for 10minutes before. Pls relogin";
    }
    else
    if(isset($user)){
    /*
    i want my idle time to be 10m and member ses to automatically expire if the user idle for 10ms but if the member is not idle, he/she session should not expire.
    But i dont know how to do this, i want you people to help me out. Thanks
    */
    }
    else{
    my site code here
    }
    have connected with http://adexchat.com ?
    Fun up with
    http://forum.adexchat.com

    #2
    try this u will have to edit for ur session data

    PHP Code:
    setcookie("phpsessid",$_COOKIE['phpsessid'],strtotime("+10 minutes"),"/"); 

    Comment


      #3
      Originally posted by ori View Post
      try this u will have to edit for ur session data

      PHP Code:
      setcookie("phpsessid",$_COOKIE['phpsessid'],strtotime("+10 minutes"),"/"); 
      if not works. you can use
      PHP Code:
      setcookie(session_name(), $_COOKIE[session_name()], time() + 600"/"); 
      ;-) or, use simply

      PHP Code:
      ini_set("session.gc_maxlifetime"10*60); 
      Last edited by firemax; 26.12.10, 14:31.

      Free Mobile Web Scripts by me: Free Youtube Downloader, Tweets Reader, Facebook Wall Posts Reader
      PHP Tutorials: How to Secure Your PHP Script (PHP SECURITY)
      Want to Develop/Edit your WAP/Web Site? Add me to Gtalk (gmail) 'lakshan1989' or PM me.

      Comment


        #4
        Thanks ori and firemax, i am on mobile version so i cant click tns button. But i still not understand you guys. It is like this?
        if(!isset($_SESSION)){
        print 'lol no session or idle time xpire';
        }
        else if(isset($_SESSION)){
        setcookie(sesssion_name(),$_COOKIE[session_name()],time()+600"/");
        echo " hay! you are lazy to click for 10ms. And you session has expire, so you need to login again";
        }
        esle{
        site code here lol
        }
        have connected with http://adexchat.com ?
        Fun up with
        http://forum.adexchat.com

        Comment


          #5
          Exuse. Wherd d0 we place dis code, login.php?

          Comment


            #6
            you use the code where session is created or use it to update expire time

            Comment


              #7
              Originally posted by adex3g View Post
              Thanks ori and firemax, i am on mobile version so i cant click tns button. But i still not understand you guys. It is like this?
              if(!isset($_SESSION)){
              print 'lol no session or idle time xpire';
              }
              else if(isset($_SESSION)){
              setcookie(sesssion_name(),$_COOKIE[session_name()],time()+600"/");
              echo " hay! you are lazy to click for 10ms. And you session has expire, so you need to login again";
              }
              esle{
              site code here lol
              }

              PHP Code:
              //logme.php

              $user=$_GET['user'];
              $_SESSION['ses']=$user;
              $timeout=time()+600;
              $_SESSION['sesexpire']=$timeout;


              //home.php

              $user=$_SESSION['ses'];
              if(!isset(
              $user) || ($_SESSION['sesexpire'] < time()))
              {
                  
              session_destroy();    
                  echo 
              "you are not login or you idle for 10minutes before. Pls relogin";
              }
              else{
                  
              $timeout=time()+600;
                  
              $_SESSION['sesexpire']=$timeout;
                  
              //your site code here


              Free Mobile Web Scripts by me: Free Youtube Downloader, Tweets Reader, Facebook Wall Posts Reader
              PHP Tutorials: How to Secure Your PHP Script (PHP SECURITY)
              Want to Develop/Edit your WAP/Web Site? Add me to Gtalk (gmail) 'lakshan1989' or PM me.

              Comment


                #8
                Thank you! @firemax
                but how can i support it with cookie to remember member pass and nickname for auto login. Mean like facebook login.
                have connected with http://adexchat.com ?
                Fun up with
                http://forum.adexchat.com

                Comment


                  #9
                  $_SESSION['username'] = $_POST['username'];
                  $_SESSION['password'] = $_POST['password'];

                  Comment


                    #10
                    U need to update always the time, in every php file you are g0ing to click.. I used cp n0w for br0wsing hehe, i cant p0st d c0de right n0w

                    Comment

                    Working...
                    X