views:

43

answers:

2
function redirect($url){
    header("HTTP/1.1 303 See Other");
    header("Location: $url");
    exit();
}

I have the function called when certain input buttons are clicked.

The session is set on every page, and it IS passed if the the button is clicked within 5 minutes. But the session is lost after about 5 minutes if the button is clicked.

If I refresh the page (not redirect) the session is not lost, so I'm pretty sure it's not a timeout issue. What could be causing this?

A: 

Hey!

Try editing this part of your php.ini file and restart apache:

; TTL for user-defined php.ini files (time-to-live) in seconds. Default is 300 seconds (5 minutes)
;user_ini.cache_ttl = 300
akellehe
What would that do?
kylex
Uncommenting the user_ini.cache_ttl and increasing the number would extend the time-to-live on the user's cache. It's set at 5 minutes by default. It's most likely where your problems are coming from.(You have to restart apache in order for changes to php.ini to take effect)
akellehe
Sadly, it did not work.
kylex
Is it LAMP or WAMP? On WAMP some metapackages make funny extra php.ini files that don't actually change the configuration. In LAMP there is a php.ini file for both the php-cli and server installations....and...just to be sure; you got rid of the ";" at the front of the line? I apologize for the silly question. Just making sure.
akellehe
It is on a LAMP stack.
kylex
Ok... When you redirect does it go to the same domain? Or a subdomain? Also; do you have cookies enabled?
akellehe
+1  A: 

Figured it out. Needed to add this line to my custom php.ini file. For some reason the session needs an explicitly direct session file to save in a local directory.

session.save_path = /path/to/tmp

kylex
nice, thanks for posting.
akellehe