douxiong3245 2013-05-03 21:32
浏览 46

非常奇怪的问题,$ _SESSIONs无法正常工作,而favicon在第二次刷新之前没有显示?

So, i am working on this website:

http://www.funkydictionary.com/signup.php

And i have run in to a very weird issue that i have not had before, i have a login page, and a signup page so far, server language is PHP, i pass error and success msges via sessions, so, when a user tries to log in, or register, a success or failure $_SESSION is set.

And he is redirected to the signup page where his error/success will be shown.

Now for some odd reason, sessions cannot be set, and i noticed that the favicon is not displayed either, until the browser is refreshed ?

When this has happend, everything works fine, but if the browser is clossed and thereby all sessions unset, the samme issue occurs?

I am guessing this has something to do with the server configs?

Any help is appreciated

EDIT 1:

This is included at the top of everypage:

<?php
session_start();

if(isset($_SESSION['login']) && $_SESSION['login'] == 1) {

    $error_message = "";
    $success_message = "";

    $now = time(); // checking the time now when home page starts

    if($now > $_SESSION['expire'])
    {
        session_unset();
        session_destroy();

        global $loggedIn;
        $loggedIn = null;

        $error_message = 'Your session has expired, please login again.<br />';

        session_start();
        $_SESSION['error'] = $error_message;

        died($success_message, $error_message, '/login.php');
    }
    else {

    global $loggedIn;
    $loggedIn = 1;  
    }
}
?>

EDIT 2:

When/How do sessions expire?

Well on login i set a session ['start'] = time(); and ['expire'] = start + 60*60

here is the code

    session_start();
    $_SESSION['login'] = "1";
    $_SESSION['username'] = $row['username'];

    $_SESSION['start'] = time();// taking now logged in time
    $_SESSION['expire'] = $_SESSION['start'] + (60 * 60) ; // ending a session in 30     minutes from the starting time

    global $loggedIn;
    $loggedIn = 1;

    $success_message = 'You have logged in as ' . $row['username'];
    died($success_message, $error_message, '/login.php');
  • 写回答

1条回答 默认 最新

  • dongqiang8058 2013-05-03 22:20
    关注

    Ok, i fixed it, i have no idea what exactly fixed it, but i changed some session_start() input form and session error handeling, favicon seems updated now aswell, as in, the new favicon

    评论

报告相同问题?

悬赏问题

  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端