Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8511115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:53:54+00:00 2026-06-11T03:53:54+00:00

My website relies completely on a random page generator that loads a page from

  • 0

My website relies completely on a random page generator that loads a page from a text file list. The code was kindly written by “lserni” on the forum. The script has been working perfectly the last few days, and it’s happily processed over 100,000 page views in 3 days!

I noticed today however that it seems to have stopped working properly. If you are a brand new visitor to the page, or you’ve cleared your internet cache/cookies etc – When you load the page for the first time, it doesn’t randomly generate a page.. it just shows a BLANK page. If you then refresh the page, the script works perfectly. I just can’t get my head round it, but it’s now resulted in a large drop in traffic! Hope you can help:

    <?php

    session_start();
    if (!isset($_SESSION['urlist']))       // Do we know the user?
        $_SESSION['urlist'] = array();     // No, start with empty list
    if (empty($_SESSION['urlist']))        // Is the list empty?
    {
        $_SESSION['urlist'] = file("linklist.txt");   // Fill it.
        $safe = array_pop($_SESSION['urlist']);
        shuffle($_SESSION['urlist']);           // Shuffle the list
        array_push($_SESSION['urlist'], $safe);
    }
    $url = trim(array_pop($_SESSION['urlist']));
    header("Location: $url");
    ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T03:53:56+00:00Added an answer on June 11, 2026 at 3:53 am

    It’s actually the LAST item in the file that’s used first if there is no session data.

    {
        $safe = array_pop($_SESSION['urlist']); // gets item at the END of the array
        shuffle($_SESSION['urlist']);
        array_push($_SESSION['urlist'], $safe); // puts item at the END of the array
    }
    $url = trim(array_pop($_SESSION['urlist']));// gets item at the END of the array
    

    So if you introduced a newline in your textfile at the end, it may be your issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a website project under version control that relies on files from an
I have a large, dynamically generated, single page website that heavily relies on javascript.
I have a bunch of code that's already written which currently relies on images
I am developing a website that relies on pulling the geolocation data of a
I have an existing PHP/MySQL website that relies hugely on form POSTs for things
Our website relies on images from one of our manufacturers. The image directories are
I am developing a website that relies much on XML data. The web site
I have a python application that relies on a file that is downloaded by
My Description I have a website application that relies heavily on Javascript and JQuery.
I have a website that relies heavily on a Creole parser for allowing wiki

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.