简体   繁体   中英

How can session_start cause my page to get stuck

Ive seen a few people with the same problem, and I created a VERY simple test file. So I'm SURE its because of session_start . I've had this wired problem for days now and narrowed things down to this....

MY TEST FILE :) I basically start my page with <? @session_start(); ?> <? @session_start(); ?> <? @session_start(); ?> (nothing before the first <? not even a space) Then create $myyear = date("Y"); And if $myyear > 2000 I refresh the page after 2 seconds (with a meta refresh)

So it keeps refreshing, refreshen refreshing.... but after about a minute it gets stuck.

if i remove session_start or @session_start it suddenly works forever. So it can only be session_start causing the problem -> even through i don't even create a real session.

Any idea how this can be fixed? or what i should be looking for?

Based on your description, I've come up with the following code:

<?php
    session_start();
    $myyear = date('Y');
    if ($myyear > 2000) {
        echo('<meta http-equiv="refresh" content="2">');
    }
?>
Page Contents (<?php echo(time()) ?>)

This works as expected for me.
If it works for you as well, please figure out what's different between your code and this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM