Jump to content

Recommended Posts

So I made this basic user system where every guest can register, log in, change their details etc. But the problem is that if they stay on one page for too long (i.e reading a long article) and then click somewhere, they have to login again, which is quite annoying.

 

So could anyone tell me, how could I increase the log-in time of a user. I already tried increasing session expire time, but that didn't work. I googled alot but didn't find much there either, only a few tips and advices but those didn't work either.

 

Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/193195-increasing-users-log-in-time/
Share on other sites

I used sessions.

 

 

I did, at first it said I have no permissions. Then I removed the part where it made an extra folder for sessions, after that it didn't give an error but it didn't work either. My user logs out already after 10 minutes, shouldn't the default value should be like 24 minutes or something?

session_cache_expire()

 

call that with an argument of how many minutes you want.. BEFORE session_start();

 

I.E... if you want them to have an hour of login.. then go

session_cache_expire(60);

 

Didn't work. I set it up for 60 minutes and then was idle for 50 minutes but still logged out.

No don't use client side cookies to auto-login a user many do something like:

 

$_COOKIE['username'] = $username;
$_COOKIE['password'] = $password;

 

And then one of your users logs in on a public computer and his data is readable by any competent hacker that uses that computer after him

 

Try any of the below options:

 

session_cache_expire

session_set_cookie_params

It also depends on your system settings, Is this a home brew server? Is it a hosting company (which)? Is it linux or windows based. What are your privilege settings for your hosting (if its home brew did you check your apache config make sure your session directory is set right, your time out for sessions on the server itself are set sometimes this can override your script commands..

 

Side note: for the hell of it.. try

<?php print_r($_SESSION); ?>

somewhere lower in your script (maybe the bottom of the page, and see if your sessions are being captured.

It's not about my code, never has been.

 

I got it to work by the way, partially atleast.. I had to make a new session folder manually in ftp.

Now I set it to 5400 (1,5h) but it logs me out after 50 minutes. I'm happy with the 50 minutes already, but just curious, why won't it go all the way to 1,5h?

 

Here are some values I wrote into htaccess:

 

php_value session.gc_maxlifetime 5400
php_value session.cookie_lifetime 5400
php_value session.gc_divisor 1
php_value session.save_path /new_sessions/

 

Any ideas?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.