Jump to content

Recommended Posts

Hey everybody,

With school I've been quite busy; thus, my absence from the forums. But I am here, on my free time, with a question.

I log in fine, and surf my website, go to other ones, but when I come back I'm logged out. Now I'm thinking I didn't set my session right correctly. I check back and they seem fine.

 

So I log in again, reload my webpage a couple of times, and then I "log out". This means that when I refreshed the login inputs show up. This is bad because I have those show up if a person is not logged in(meaning the sessions aren't set). This means that the sessions are either being destroyed, or aren't being set right.

 

But the last option is that my host is messed up, because I have the same thing running at another host and it works fine.

 

Any thoughts, solutions?

Thank you for your time

~L

Link to comment
https://forums.phpfreaks.com/topic/71022-session-randomly-being-destroyed/
Share on other sites

As you say... 2 possible reasons:

1. Check php.ini to find out length of session, 'cookie_lifetime' should be set to '0' for 'until browser closed'.

2. Do a grep for 'session_destroy', 'session_unregister', 'session_unset', 'session_write_close', ... there are other ways you may change or reset the session, but these are the more probable. Especially the unset, thinking your just getting rid of vars, e.g.

Do NOT unset the whole $_SESSION with unset($_SESSION) as this will disable the registering of session variables through the $_SESSION superglobal.

If you use a host then you'll probably not have access to it. You can view it by making a php page such as:

<?php
echo phpinfo();
?>

Here's some refs for handling from php:

http://uk3.php.net/manual/en/function.phpinfo.php

http://uk3.php.net/manual/en/function.ini-get.php

http://uk3.php.net/manual/en/function.ini-set.php

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.