You are here: Re: sessions vs cookies « PHP Programming Language « IT news, forums, messages
Re: sessions vs cookies

Posted by Juha Suni on 12/09/05 16:27

Atte Andrι Jensen wrote:
> Hi
>
> I'm developing a site where I'd like to store information during a
> users visit. So far I've been using sessions, but as far as I can
> tell it's not possible to control for how long a session is valid. It
> seems that
> these information are valid until the browser closes.
>

Sessions use cookies. The cookies are used to store the users Session ID.
These cookies by default have their lifetime set to 0 (meaning that the
cookie expires when the browser is closed). You can change this from php.ini
with session.cookie_lifetime, or using the
session_set_cookie_params -function from within the script.

See
http://www.php.net/session
and
http://www.php.net/manual/en/function.session-set-cookie-params.php

Please note that these settings only affect the cookie. While the cookie
might persist in the browser (if it is kept open for a long time), the
actual session data stored on the server might be gone. By default the PHP
garbage collection clears up sessions that have not been used for 24
minutes. To change sessions lifetimes use session.gc_maxlifetime in php.ini.
Please note that even this might not be enough if some other scripts, with
smaller timeouts, use the same folder for storing the session data (Their
garbage collection would trash session files in the folder according to
their timeout rules). To avoid this, you would need to set the script to use
a different session save path (session.save_path).

Usually sessions are all you need. Setting the session timeout to higher
than 24 minutes takes a few steps but is not a problem.

HTH

--
Suni

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация