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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:11:09+00:00 2026-05-18T09:11:09+00:00

index.php session_start(); if(!isset($_GET[‘n’])) { $_SESSION[‘foo’] = bar; header(Location: /index.php?n=D); } echo FOO: .$_SESSION[‘foo’]; This

  • 0

index.php

session_start();

if(!isset($_GET['n'])) {
  $_SESSION['foo'] = "bar";
  header("Location: /index.php?n=D");
}

echo "FOO: ".$_SESSION['foo'];

This page index.php is used in a subdomain. The subdomain is a folder in the root domain, i.e.

 - WWW
    - SUB DOMAIN
      - index.php

The session variable foo is set on page call, then checked after a redirect header – and it’s gone.

I’ve tried:

  • ini_set('session.cookie_domain','.example.com');
  • Various combinations of session_set_cookie_params()
  • Location: http://subdomain.example.com
  • Tearing my hair out

but nothing seems to be working. Seems like a very simple problem – can someone help me find my lost cookie / session / variable ?

EDIT

var_dump(session_get_cookie_params()) yields

array(5) { ["lifetime"]=> int(0) ["path"]=> string(11) "/" ["domain"]=>
 string(23) ".example.com" ["secure"]=> bool(false) ["httponly"]=> bool(false) } 

My URL has a dash - in it (my-example.com). Could this be the problem?

Also tried setting session_name() before params. Still not working.

  • 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-05-18T09:11:10+00:00Added an answer on May 18, 2026 at 9:11 am

    After five hours of trying myself, I finally contacted my hosting provider and they had a look.

    The verdict? session.save_path in php.ini had not been set. The script above is now running properly.

    If someone cares to elaborate on the whys and hows and whatnot, I’ll be happy to give them the solution, otherwise I’ll have to accept my own.

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

Sidebar

Related Questions

include 'header.php'; // ... some code header('Location:index.php'); exit; The above code keeps giving me
I wanna rewrite links like index.php?page=entry&id=15&action=edit to entry/15/edit . This is how my .htaccess
Let's imagine I got this: index.php generates form with unpredictable number of inputs with
I have an index.php file which has to process many different file types. How
From http://projecteuler.net/index.php?section=problems&id=99 Comparing two numbers written in index form like 2 11 and 3
Let's say we have index.php and it is stored in /home/user/public/www and index.php calls
I am wondering how I can break up my index.php homepage to multiple php
Is there a possible htaccess directive that can transparently forward request from index.php to
I have an htaccess file that uses mod_rewrite to redirect /controller to /index.php?controller=%controller% Like
I need to perform a HTTP GET from PHP. More specifically, from within /index.php

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.