I have users who write articles and when they leave there computer for a while and come back then submit a post the author / user_id is recorded as a NULL value. I’m assuming the session is expiring. I have:
ob_start();
session_start();
if(isset($_SESSION['user_id'])) {
$ext = time() + 31560000;
setcookie('name', $_SESSION['user_id'], $ext);
}
On the top of the index page where a user is redirected upon login.
Also, this is what happens when they actually log in:
$user_id = get_user_id($some_variable); // get's the user_id
$username = get_username($some_variable); // get's username
$_SESSION['user_id'] = $user_id;
?>
<script type="text/javascript">
window.location = 'http://site.com/<?php echo $username; ?>';
</script>
<?php
exit();
Is this properly configured, and why would the user’s sessions be expiring? They’re not exiting the browser, it’s just inactivity. What would be causing this?
I don’t know what you try to achieve with
But that do not increase the php session lifetime, but only create a cookie called name that have the $_SESSIOn[‘user_id’] as value and expire 31560000 seconds after creation.
If you want to change your session lifetime see session.configuration