PDA

View Full Version : Yet another question.. (PHP)


jlp09550
09-19-2007, 04:50 PM
Alright, I was going to post this on PHPFreaks.COM, but I decided since VPL needs more topics/posts, I'll post it here and let those evil PHP experts here resolve this issue, if possible.

Okay, so, I'm using these lines of code:

ini_set('session.gc_maxlifetime', strtotime("+1 month"));
ini_set('session.cookie_lifetime', strtotime("+1 month"));
session_set_cookie_params(strtotime("+1 month"));

These are supposed to extend the session time to 1 month.. however, this is not happening, yet the PHPINFO shows it is changed.

I don't understand why, but it is server side, since Firefox reports the cookie lasts for a month actually.

Help?

Sar
09-19-2007, 05:16 PM
Have you tried deleting cookies to begin with?

Vivacity
09-19-2007, 05:50 PM
You can always try being more specific
session_set_cookie_params ( int $lifetime [, string $path [, string $domain [, bool $secure [, bool $httponly]]]] );

Include $path, and $domain, see if that makes any difference.

Also, this needs to be noted ->
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_cookie_params() for every request and before session_start() (http://us3.php.net/function.session-start.php) is called.

Haywire
09-20-2007, 04:29 AM
Haha, simple simple:P


<?php
setcookie('title', 'data', time()+2592000, '/', '.yourdomain.com');
}


That should expire.... In about a month.

jlp09550
09-20-2007, 05:19 PM
Haha, simple simple:P


<?php
setcookie('title', 'data', time()+2592000, '/', '.yourdomain.com');
}


That should expire.... In about a month.
LIke I said, I want a SESSION extension, I never will use cookies.

Sar
09-20-2007, 06:06 PM
LIke I said, I want a SESSION extension, I never will use cookies.

Why would you want to be logged in for a month on a site that doesn't use cookies? You're better off setting it at some point of being inactive (like this forum) for security reasons, and that most people aren't going to shove their computers into Hibernation or Suspend unless they're on a laptop or running Vista.

FuRom
09-20-2007, 06:13 PM
Just go about it like you would to just set a new cookie. It generally works, I've yet to see it not work.

IE: What haywire said.

When you set a cookie of the same name that already exists the browser will just update the cookie information

OwlManAtt
09-20-2007, 08:34 PM
LIke I said, I want a SESSION extension, I never will use cookies.Sessions work by setting a cookie with a session ID on the user's machine. That ID maps to a temporary file stored somewhere on the server with the actual data in it.

So, you *are* using cookies, to some extent.