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 9060387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:13:00+00:00 2026-06-16T15:13:00+00:00

When a user visits a certain page on my site the script below runs

  • 0

When a user visits a certain page on my site the script below runs once. This works perfectly, but for some reason after it runs the one time, the session is cleared and is set to “0”.

The session name is “user_zip” and here is the code that is somehow clearing the session.

$user_zip_query = "SELECT * FROM dev_cities WHERE city_zip = '".$_SESSION['user_zip']."'";
$user_zip = mysql_query($user_zip_query);
$userziprow = mysql_fetch_assoc($user_zip);
$state = $userziprow['city_state'];
$county = $userziprow['city_county'];
$city = $userziprow['city_name'];

Any idea what could be causing this?

The Session is started in an included class file with this code…

 public function __construct() {

        include_once("includes/userconfig.php");                  // include database constants        

        if ($this->checkDatabase()) {                   // check for database connection

            session_start();                            // create session
  • 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-16T15:13:02+00:00Added an answer on June 16, 2026 at 3:13 pm

    Your code has quotes in the session which is also surrounding by quotes which is cancelling out the session change it to this:

    $uzip = $_SESSION['user_zip'];
    //highly recommend use add SQL injecton prevention here how ever
    $user_zip_query = mysql_query("SELECT * FROM dev_cities WHERE city_zip = '$uzip'") or die(mysql_error());
    
    $row = mysql_fetch_assoc($user_zip_query);
    $state = $row['city_state'];
    $county = $row['city_county'];
    $city = $row['city_name'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A typical browser based user visits site (A), then links to some sub page
This should be a simple logic problem but for some reason I've been struggling
Say a user visits the page http://somedomain.com/path/file.html#foo , I'd like to display, using JavaScript,
When the user visits the site, I can get their country code. I want
If a user visits www.example.com/forum could this point to another server/IP without changing the
When a user visits our site they see a coverflow. They are not logged
so, when a user visits the site for the first time i want to
I notice that the first time a user visits my site the Wicket-generated URLs
I want to track the number of user visits to a site. A visit
I am trying to create the following condition 1) User visits page 2) User

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.