FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » sessions timeout
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: sessions timeout [message #176411 is a reply to message #176406] Wed, 04 January 2012 11:54 Go to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 1/3/2012 8:42 PM, Michael Joel wrote:
> I am on a shared server so I have no control over the settings.
>
> Is there a way for me to set a "timeout" for sessions?
>
> I am working on some scripts (logged in as a test user) and had been
> away from it for a few hours. The tabs (this is Opera browser) were
> closed, but not the browser.
>
> When I went back to the page it still had me logged in.
> Obviously the server session cookies are set to clear when the browser
> closes.
>
> Is there a way for me to have some control over this and set a time
> limit so after a reasonable amount of time the session cookie clears?
>
> Thanks
> Mike

If your hosting company allows you to set PHP values in your .htaccess
file (most do, at least for some functions), the easiest would be to set
it in your .htaccess file. Then you don't need to keep checking in all
of your code. Something like:

php_value session.cookie_lifetime 3600
php_value session

Would set the value to 1 hour (3600 seconds).

And since you're using a different value than the system default, so you
would want to use your own session save path, i.e.

php_value session.save_path /my/session/save/path

Where the directory would be not be available to the web but would be in
your path, i.e. if your website root were:

/var/www/example/html

(example being your root directory), you might want to place them in

/var/www/example/sessions

And finally, to keep things cleaned up, you might want to set the
garbage collection lifetime to the same value as your cookie lifetime, i.e.

php_value session.gc_lifetime 3600

This will help keep things cleaned up.

One other note: if you can't set these in your .htaccess directory, you
might be able to set them in your own php.ini file in you root
directory, but this isn't as common. If you do, ensure you set your
..htaccess file up to deny access to your own php.ini file.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Give me the names of some CRM php projects
Next Topic: transfering all MySQL rows to an array
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 07:46:30 GMT 2024

Total time taken to generate the page: 0.04518 seconds