php session expiry

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • harintfs
    New Member
    • Dec 2011
    • 17

    php session expiry

    Dear
    I would like to set session expire time to 3hrs,
    Which one is best ?
    ini_set("sessio n.cookie_lifeti me","10800"); or session_set_coo kie_params(3600 * 3);
    Or can I use both?
    Is it compulsary to place every page b4 where ever session_start() ;
    And one more above said syntax is correct or not? because some people using "10800" and some '10800' others just 10800. how to set?

    Thanks. Pls help me
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    both of them will do the same trick

    but 10800 is better than 3600*3, php wont have to parse unnecessary equation. And yes you can use whichever you want.

    Yes it is compulsory. in simple when you do session_start it creates all the necessary data list for you page purpose.

    "10800" , '10800' and 10800

    all of them are correct. it may have performance issue, i am not sure about it though.

    but in some cases they will show difference

    such as
    ("10800"==10800 ) will return 1 i.e. true

    ("10800"===1080 0) will return false

    cause in the second comparison first data is treated as string and the second data is treated as number.

    Comment

    • harintfs
      New Member
      • Dec 2011
      • 17

      #3
      Great,
      Thanks lot,
      Then why there is two functions for same purpose?
      anyway thanks once again. Let i work with this, If problem persists, I ll inform y.

      Comment

      • harintfs
        New Member
        • Dec 2011
        • 17

        #4
        Dear Friend,
        I used session_set_coo kie_params(1080 0); But now I am facing some problem. After 1 hr (on 65th min)even with activity (frequent clicks on page) at the time of submitting my page its expires, What may be problem? How to fix it?. I tried to work 45 min with activity and submit there is no expiry problem.
        I am using shared hosting.

        Comment

        • johny10151981
          Top Contributor
          • Jan 2010
          • 1059

          #5
          here is a suggestion from php.net site

          Set cookie parameters defined in the php.ini file. The effect of this function only lasts for the duration of the script. Thus, you need to call session_set_coo kie_params() for every request and before session_start() is called.

          Comment

          • harintfs
            New Member
            • Dec 2011
            • 17

            #6
            Yes, I using session_set_coo kie_params(1080 0); before calling session_start .. each page. Wheter I need edit php.ini? And also I am attaching my current php.ini config file.
            Thanks
            Attached Files

            Comment

            Working...