Jump to content

[SOLVED] session problem


jakebur01

Recommended Posts

I installed this hesk ticket submission deal for a website. I am having trouble with the session and was hoping someone could help me figure it out.

 

It is telling me:

Your session has expired, please login using the form below.

 

Here is the code:

define('IN_SCRIPT',1);

/* Get all the required files and functions */
require_once('hesk_settings.inc.php');
require_once('language/'.$hesk_settings['language'].'.inc.php');
require_once('inc/common.inc.php');
hesk_session_start();
require_once('inc/database.inc.php');
hesk_dbConnect() or hesk_error("$hesklang[cant_connect_db] $hesklang[contact_webmsater] $hesk_settings[webmaster_mail]!");

/* What should we do? */
$action=hesk_input($_REQUEST['a']) or $action='login';
if ($action == 'login') {print_login();}
elseif ($action == 'do_login') {do_login();}
elseif ($action == 'logout') {logout();}
else {hesk_error($hesklang['invalid_action']);}

/* Print footer */
require_once('inc/footer.inc.php');
exit();

/*** START FUNCTIONS ***/

function do_login() {
global $hesklang;
$user=hesk_isNumber($_POST['user'],$hesklang['select_username']);
$pass=hesk_input($_POST['pass'],$hesklang['enter_pass']);

$sql = "SELECT * FROM `hesk_users` WHERE `id`=$user LIMIT 1";
$result = hesk_dbQuery($sql) or hesk_error("$hesklang[cant_sql]: $sql</p><p>$hesklang[mysql_said]:<br>".mysql_error()."</p><p>$hesklang[contact_webmsater] $hesk_settings[webmaster_mail]");
$res=hesk_dbFetchAssoc($result);
foreach ($res as $k=>$v) {
    $_SESSION[$k]=$v;
}

/* Check password */
if ($pass != $_SESSION['pass']) {
hesk_session_stop();
hesk_error($hesklang['wrong_pass']);
}

/* Regenerate session ID (security) */
hesk_session_regenerate_id();

/* Get allowed categories */
if (empty($_SESSION['isadmin'])) {
$cat=substr($_SESSION['categories'], 0, -1);
$_SESSION['categories']=explode(",",$cat);
}

session_write_close();

if ($url=hesk_input($_REQUEST['goto'])) {
    $url = str_replace('&','&',$url);
    Header('Location: '.$url);
} else {
    Header('Location: admin_main.php');
}
exit();
} // End do_login()


function print_login() {
global $hesk_settings, $hesklang;
require_once('inc/header.inc.php');
?>
<p class="smaller"><a href="<?php echo $hesk_settings['site_url']; ?>"
class="smaller"><?php echo $hesk_settings['site_title']; ?></a> >
<?php echo $hesklang['admin_login']; ?><br> </p>
</td>
</tr>
<tr>
<td>

<p> </p>

<h3 align="center"><?php echo $hesklang['login']; ?></h3>

<?php
if ($_REQUEST['notice']) {
echo '<p align="center" class="important">'.$hesklang['session_expired'].'</p>';
}
?>

<form action="admin.php" method="POST">

<div align="center">
<center>
<table border="0" cellspacing="1" cellpadding="5">
<tr>
<td align="right"><?php echo $hesklang['user']; ?>: </td>
<td><select name="user">
<?php
$sql = "SELECT * FROM `hesk_users`";
$result = hesk_dbQuery($sql) or hesk_error("$hesklang[cant_sql]: $sql</p><p>$hesklang[mysql_said]:<br>".mysql_error()."</p><p>$hesklang[contact_webmsater] $hesk_settings[webmaster_mail]");
while ($row=hesk_dbFetchAssoc($result))
{
    echo '<option value="'.$row['id'].'">'.$row['user'].'</option>';
}

?>
</select></td>
</tr>
<tr>
<td align="right"><?php echo $hesklang['pass']; ?>: </td>
<td><input type="password" name="pass"></td>
</tr>
</table>
</center>
</div>

<p align="center"><input type="hidden" name="a" value="do_login">
<?php
if ($url=hesk_input($_REQUEST['goto'])) {
echo '<input type="hidden" name="goto" value="'.$url.'">';
}
?>
<input type="submit" value="<?php echo $hesklang['login']; ?>" class="button"></p>

</form>
<?php
} // End print_login()

function logout() {
global $hesk_settings, $hesklang;
require_once('inc/header.inc.php');
hesk_session_stop();
?>
<p class="smaller"><a href="<?php echo $hesk_settings['site_url']; ?>"
class="smaller"><?php echo $hesk_settings['site_title']; ?></a> >
<?php echo $hesklang['logged_out']; ?><br> </p>
</td>
</tr>
<tr>
<td>

<p> </p>
<h3 align="center"><?php echo $hesklang['logout']; ?></h3>
<p> </p>

<p align="center"><?php echo $hesklang['logout_success']; ?></p>
<p> </p>
<p align="center"><a href="admin.php"><?php echo $hesklang['click_login']; ?></a></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<?php
require_once('inc/footer.inc.php');
exit();
} // End logout()

 

I can't figure out what's wrong. I know that my sessions are working ok. I created a session on a test page and then I displayed that session on a second test page.

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.