2

Im trying to make a steam login on my website.

I used this steam login, it works fine but the only problem is that after sometime my session expires and I need to log in again. On the sites I've been on it could be weeks and the session wouldn't expire. I think I could do it using cookies but I don't know how.

I've searched on the internet solutions but ended up getting nothing so I'm here.

Community
  • 1
  • 1
Nikita
  • 93
  • 7
  • 1
    Can you check your `php.ini` for the value of `session.cookie_lifetime`? It's possible you need to specify a longer time for your session cookies to last. – Worthwelle Jun 07 '18 at 15:29
  • It's on `0` right now, how much should I put it on? For example to last for a week. 604800 ? – Nikita Jun 07 '18 at 15:37
  • 1
    A value of `0` means the cookies sticks around until you close your browser. Try setting it to 24 hours by setting it to `86400`. The value is represented [in seconds](http://www.php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime). Alternatively, you could use [ini_set](https://stackoverflow.com/a/9797962/9882907) at the start of your file if you don't want to change the setting globally. – Worthwelle Jun 07 '18 at 15:44
  • @Worthwelle Yes, It's displaying that the cookie will expire in a week. Shouldn't I change any other values like `session.gc_maxlifetim` or something? – Nikita Jun 07 '18 at 16:00

1 Answers1

2

You should change the value of session.cookie_lifetime to a number in seconds in the php.ini file you're using. For example, if you're using PHP 5.6 fpm you should go to the directory of the php 5.6 fpm, for me it's /etc/php/5.6/fpm there's a php.ini file, change it and then go to the terminal and write there /etc/init.d/php5.6-fpm restart to restart the service. Refresh the website and it should be working.

Nikita Ivanov
  • 505
  • 1
  • 4
  • 18