0
votes

I never unset a $_SESSION variable or destroy the session but the next day I'll come to the site and the session will be gone.

I'm doing a simple $_SESSION['name'] = $_POST['name'] and then it forgets about the session.

Am I doing something wrong? Do I set a time-limit for SESSION vars?

Why would it expire?

Thanks.

1
In many configurations, PHP periodically garbage collects old sessions. - Barmar
session_set_save_handler() may be of interest to you. - Shea

1 Answers

0
votes

but the next day I'll come to the site and the session will be gone.

Sessions are not meant to behave that way. Sessions expire as soon as you close your browser. You need cookies to achieve this.

You also need to have a look at session.gc_maxlifetime

You can do like this

<?php
ini_set('session.gc_maxlifetime', 3600);