How do I set one?
Adding the following code to .htaccess still only makes sessions last a few hours.
php_value session.gc_maxlifetime 604800 php_value session.cookie_lifetime 604800
Offline
dvd4 wrote:
you can also set the php session cookie expire date in the php script too...
How do I do that?
Edit: also, the cookie isn't the problem...the server throws out data that's older than a few hours.
Last edited by jvvg (2012-09-09 20:31:44)
Offline
jvvg wrote:
dvd4 wrote:
you can also set the php session cookie expire date in the php script too...
How do I do that?
Edit: also, the cookie isn't the problem...the server throws out data that's older than a few hours.
why do you need sessions to last more than a few hours anyway ?
Offline
dvd4 wrote:
jvvg wrote:
dvd4 wrote:
you can also set the php session cookie expire date in the php script too...
How do I do that?
Edit: also, the cookie isn't the problem...the server throws out data that's older than a few hours.why do you need sessions to last more than a few hours anyway ?
Because I'm making a login that remembers the user.
Offline
jvvg wrote:
dvd4 wrote:
jvvg wrote:
How do I do that?
Edit: also, the cookie isn't the problem...the server throws out data that's older than a few hours.why do you need sessions to last more than a few hours anyway ?
Because I'm making a login that remembers the user.
So, it remembers that the user is logged in, like facebook does? You can set a cookie to the same content as the session variable and set its expiration to far in the future. Then, in all your scripts (or at least some of them) have this code:
<?php session_start(); $_SESSION['value'] = $_COOKIE['value']; ?>
But the client needs cookies on.
Offline
GP1 wrote:
jvvg wrote:
dvd4 wrote:
why do you need sessions to last more than a few hours anyway ?Because I'm making a login that remembers the user.
So, it remembers that the user is logged in, like facebook does? You can set a cookie to the same content as the session variable and set its expiration to far in the future. Then, in all your scripts (or at least some of them) have this code:
Code:
<?php session_start(); $_SESSION['value'] = $_COOKIE['value']; ?>But the client needs cookies on.
I would do that, but I need session variables to make it safer. Also, the cookie isn't the problem, it's the data.
Offline
jvvg wrote:
dvd4 wrote:
jvvg wrote:
How do I do that?
Edit: also, the cookie isn't the problem...the server throws out data that's older than a few hours.why do you need sessions to last more than a few hours anyway ?
Because I'm making a login that remembers the user.
Why not just put the data in a database with mySQL ?
Offline
dvd4 wrote:
jvvg wrote:
dvd4 wrote:
why do you need sessions to last more than a few hours anyway ?Because I'm making a login that remembers the user.
Why not just put the data in a database with mySQL ?
Session variables are easier, and are more efficient, because they require fewer MySQL queries.
Offline
jvvg wrote:
dvd4 wrote:
jvvg wrote:
Because I'm making a login that remembers the user.Why not just put the data in a database with mySQL ?
Session variables are easier, and are more efficient, because they require fewer MySQL queries.
Session variables are only temporary.
Offline
dvd4 wrote:
jvvg wrote:
dvd4 wrote:
Why not just put the data in a database with mySQL ?Session variables are easier, and are more efficient, because they require fewer MySQL queries.
Session variables are only temporary.
I am asking if there is a way to make them last longer (in this case, a week).
Offline
jvvg wrote:
dvd4 wrote:
jvvg wrote:
Session variables are easier, and are more efficient, because they require fewer MySQL queries.Session variables are only temporary.
I am asking if there is a way to make them last longer (in this case, a week).
probabally there is but I'm saying that there might not be a need to
Offline
session_start(); $timeout = 60; // Number of seconds until it times out. // Check if the timeout field exists. if(isset($_SESSION['timeout'])) { // See if the number of seconds since the last // visit is larger than the timeout period. $duration = time() - (int)$_SESSION['timeout']; if($duration > $timeout) { // Destroy the session and restart it. session_destroy(); session_start(); } } // Update the timout field with the current time. $_SESSION['timeout'] = time();
Offline
You code won't work XenoK, because the issue presents itself during the time a user is not actively browsing the site.
Offline
XenoK wrote:
ini_set('session.save_path', /var/my-sessions-dir/);
ini_set('session.cookie_lifetime', 2592000);
would that work? you'd place it before session_start();
No, because the problem isn't the cookie, it's the server side data.
Offline
LS97 wrote:
XenoK wrote:
ini_set('session.save_path', /var/my-sessions-dir/);
ini_set('session.cookie_lifetime', 2592000);
would that work? you'd place it before session_start();No, because the problem isn't the cookie, it's the server side data.
I'm trying the code, and the save path might do the trick.
Offline
jvvg wrote:
GP1 wrote:
Yeah, im guessing you can extend it in php.ini
But most free hosts wont let you access that... darnHowever, most do let you set PHP values in the .htaccess file.
![]()
And I know nothing about .htaccess, because I use IIS instead of Apache. If I did I would let you know
Offline
GP1 wrote:
jvvg wrote:
GP1 wrote:
Yeah, im guessing you can extend it in php.ini
But most free hosts wont let you access that... darnHowever, most do let you set PHP values in the .htaccess file.
![]()
And I know nothing about .htaccess, because I use IIS instead of Apache. If I did I would let you know
![]()
Well, the code above works (when using the ini_set() function, but would probably work in .htaccess too).
Also, I like Apache more because it's free, it's open-source, it's more compatible, and it's a lot more popular.
Offline