Jump to content

Session Fails to Expire


Antony the Awesome

Recommended Posts

Bear with me, I started session yesterday for the first time.

My sessions never expire. The php.ini on my host looks like the default php.ini with the session.gc_maxlife directive the default 1440. My code is as follows below, I put in bold what I found to be the parts that need looking at. What's wrong?
[font=Courier]
__________________________________________________
<?php
[b]session_start();[/b]

$msg="Login successful.";

[b]if($_SESSION['isLoggedIn'] = true) {
header("Location: http://script-dump.freehostia.com/alna/redirect.php?msg=$msg");
}[/b]

$dbServer = "mysql2.freehostia.com";
$dbUsername = "antmas10_rsp";
$dbPass = "thedog";

mysql_connect($dbServer, $dbUsername, $dbPass);
mysql_select_db($dbUsername) or die("Failed to grab database.");

if(isset($_POST['submit'])) {
$username=$_POST['username'];
$pass=md5($_POST['password']);
$result=mysql_query("SELECT username FROM login WHERE username='$username' AND password='$pass'");

[b] if (mysql_num_rows($result) == 1) {
  $_SESSION['isLoggedIn'] = true;
  header("Location: http://script-dump.freehostia.com/redirect.php?msg=$msg");
}[/b]
}
?>
__________________________________________________
[/font]
Link to comment
Share on other sites

It could be related to your garbage collection.  If there are very few people visiting the site, and the garbage collection in the ini file is set to a very, very low percentage, it's going to be very unlikely that it emptys out the sessions at any logical time period.  If that is your problem at all.
Link to comment
Share on other sites

I saw it last night but kind of skipped over it.

From PHP.net:
[quote]session.gc_divisor coupled with session.gc_probability defines the probability that the gc (garbage collection) process is started on every session initialization. The probability is calculated by using gc_probability/gc_divisor...[/quote]

http://www.php.net/manual/en/ref.session.php#ini.session.gc-divisor
Link to comment
Share on other sites

No, unfortunately it wouldn't. The reason it, something like that affects the actual php engine itself, the entire way sessions are handled, I am 90% sure that won't have any affect on it at all, however, since you can't kill the session early, destroy the session manually.    Go into where the session "file's" are on the server, and once per week, clear them all out? NEver encountered that type of problem before.
Link to comment
Share on other sites

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.