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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:10:47+00:00 2026-06-18T11:10:47+00:00

<?php session_start(); if(isset($_SESSION[counter])){ echo session_id(). .$_SESSION[counter]; $_SESSION[counter]++; } else{ $_SESSION[counter]=0; echo start counter; }

  • 0
<?php
session_start();
if(isset($_SESSION["counter"])){
echo session_id()." ".$_SESSION["counter"];
$_SESSION["counter"]++;
}
else{
$_SESSION["counter"]=0;
echo "start counter";
}
?>

It’s just a basic example code for session. It working find of my PC using XAMPP. But it doesn’t work at all when I put it in to my vps webserver. The out put only include”start counter” and never changed whatever I refresh the page. I checked php.ini both on XAMPP and vps. variables_order = “GPCS” request_order = “GP” register_globals = Off session.save_handler = files Above configurations are same on XAMPP and vps.

  • 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-18T11:10:48+00:00Added an answer on June 18, 2026 at 11:10 am

    It can be due to the reason that your session expires too fast on another server. Start by making sure you’re setting the session variable correctly. It’s possible that sessions either aren’t enabled or aren’t configured correctly in the php.ini file on your server.

    You can try putting this in front of the file to see any errors. When you see the error you can figure out where you have gone wrong.

    error_reporting(E_ALL);
    ini_set('display_errors', 1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<?php session_start(); if(isset($_SESSION['views'])) $_SESSION['views'] = $_SESSION['views']+ 1; else $_SESSION['views'] = 1; echo views =
So I have the index.php page. <?php session_start(); if (!isset($_SESSION['var1'])) { echo session not
<?php session_start(); if(isset($_SESSION['views'])) $_SESSION['views']=$_SESSION['views']+1; else $_SESSION['views']=1; echo Views=. $_SESSION['views']; echo '<br>'.<a href='destroy.php'>Set Counter1</a>; ?>
<?php session_start(); if(isset($_POST['sessionNum'])){ //Declare my counter for the first time $_SESSION['initial_count'] = $_POST['sessionNum']; $_SESSION['sessionNum']
here is the code <?php session_start(); if(!isset($_SESSION['user_name'])) { header('Location: login.php'); } $conn = mysql_connect(localhost,
When I execute this following code for example: cart.php?p=1&action=add <?php session_start(); if (isset($_GET['p']) &&
my code for the php page displaying the divs <?php session_start(); require_once(classlib/mainspace.php); if (isset($_SESSION['username'])==FALSE)
if(isset($_SESSION['admin'])) { echo <li><b>Admin</b></li>; } <?php session_name('MYSESSION'); session_set_cookie_params(0, '/~cgreenheld/'); session_start(); $conn = blah blah
<?php # session session_start(); # check that session is set and is valid if(!isset($_SESSION['login']))
Here is my PHP code: <?php session_start(); if ( !isset($_SESSION['index_visited']) ) { $_SESSION['page2_visited'] =

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.