Jump to content

Sessions And Stuff


Guest Stefán Örvar Sigmundsson
 Share

Recommended Posts

Guest Stefán Örvarr Sigmundsson

I'm having a lot of trouble with sessions.1. I seem to be unable to destroy the sessions I create.2. When I check to see if my 'lang' session has been set (with the isset function) it tells me the session has not been set, but still I am able to get the contents of it by writing echo $_SESSION['lang'];3. Why doesn't this work for Firefox: $_SERVER["HTTP_ACCEPT_LANGUAGE"]?Should I abandon PHP altogether?

Link to comment
Share on other sites

1. I seem to be unable to destroy the sessions I create.
You could do this:$_SESSION = array();but that's going to remove all session information, not just yours (which only applies if there are several things using sessions on the same server). When I log someone out or otherwise get rid of the session I just unset the specific things I set.unset($_SESSION['userid']);
2. When I check to see if my 'lang' session has been set (with the isset function) it tells me the session has not been set, but still I am able to get the contents of it by writing echo $_SESSION['lang'];
There's something wrong with the code, it won't tell you a variable is not set if it has a value. Are you using isset before session_start?
3. Why doesn't this work for Firefox: $_SERVER["HTTP_ACCEPT_LANGUAGE"]?
Not all browsers send the same set of HTTP headers, your copy of Firefox might not be sending the accept-language header.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...