Connecting Tech Pros Worldwide Forums | Help | Site Map

set session timeout in code

jim
Guest
 
Posts: n/a
#1: Jul 17 '05
Can I set the session timeout in my code? I don't have access to php.ini
because the site is on a shared server.



Andy Hassall
Guest
 
Posts: n/a
#2: Jul 17 '05

re: set session timeout in code


On Wed, 19 Jan 2005 12:09:18 -0600, "jim" <info@info.com> wrote:
[color=blue]
>Can I set the session timeout in my code? I don't have access to php.ini
>because the site is on a shared server.[/color]

You don't need access to php.ini: http://uk.php.net/session notes that all the
session configuration variables are PHP_INI_ALL changeable, and links to
ini_set(), the function you can use to change them.

--
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
bob garbados
Guest
 
Posts: n/a
#3: Jul 17 '05

re: set session timeout in code


Thanks for your reply. I'm brand new to php and I'm trying to troubleshoot
a session timeout problem, so my questions are probably simple... If I want
the session to last as long as the browser is open, do I put the following
line of code in ALL of my web pages?

ini_set("session.cookie_lifetime", "0");

Do I have to put this line before or after session_start();?




"Andy Hassall" <andy@andyh.co.uk> wrote in message
news:j4etu0ppaudl8qds46f41jct6dunttslpl@4ax.com...[color=blue]
> On Wed, 19 Jan 2005 12:09:18 -0600, "jim" <info@info.com> wrote:
>[color=green]
> >Can I set the session timeout in my code? I don't have access to php.ini
> >because the site is on a shared server.[/color]
>
> You don't need access to php.ini: http://uk.php.net/session notes that[/color]
all the[color=blue]
> session configuration variables are PHP_INI_ALL changeable, and links to
> ini_set(), the function you can use to change them.
>
> --
> Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
> <http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool[/color]


Andy Hassall
Guest
 
Posts: n/a
#4: Jul 17 '05

re: set session timeout in code


On Wed, 19 Jan 2005 13:54:35 -0600, "bob garbados" <bobgarbados@yahoo.com>
wrote:
[color=blue]
>Thanks for your reply. I'm brand new to php and I'm trying to troubleshoot
>a session timeout problem, so my questions are probably simple... If I want
>the session to last as long as the browser is open, do I put the following
>line of code in ALL of my web pages?
>
>ini_set("session.cookie_lifetime", "0");[/color]

Yes, although that's the default anyway - have your host changed it?
[color=blue]
>Do I have to put this line before or after session_start();?[/color]

Before.

--
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
bob garbados
Guest
 
Posts: n/a
#5: Jul 17 '05

re: set session timeout in code


My host has it set to 1200 seconds. Thanks for the help.


"Andy Hassall" <andy@andyh.co.uk> wrote in message
news:71ftu09ru56eitlafdrstvst79k7nuctka@4ax.com...[color=blue]
> On Wed, 19 Jan 2005 13:54:35 -0600, "bob garbados" <bobgarbados@yahoo.com>
> wrote:
>[color=green]
> >Thanks for your reply. I'm brand new to php and I'm trying to[/color][/color]
troubleshoot[color=blue][color=green]
> >a session timeout problem, so my questions are probably simple... If I[/color][/color]
want[color=blue][color=green]
> >the session to last as long as the browser is open, do I put the[/color][/color]
following[color=blue][color=green]
> >line of code in ALL of my web pages?
> >
> >ini_set("session.cookie_lifetime", "0");[/color]
>
> Yes, although that's the default anyway - have your host changed it?
>[color=green]
> >Do I have to put this line before or after session_start();?[/color]
>
> Before.
>
> --
> Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
> <http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool[/color]


Closed Thread