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

  • Home
  • SEARCH
  • 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 7869621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:23:01+00:00 2026-06-03T01:23:01+00:00

How can I get session variables to persist across header redirects? My header redirect

  • 0

How can I get session variables to persist across header redirects?

My header redirect looks like this: header("Location:./content/user_dash.php");

I have session_start(); at the top of every page.

I have tried before my header redirect session_regenerate_id(true);

I have tried before my header and after session_regenerate_id redirect session_write_close();

I have tried exit(0); and die(); after my header redirect;

I have tried header("Location:./content/user_dash.php?PHPSESSID=".session_id());

If I INCLUDE the end page it works (But I cannot use this) and when I change it to redirect my variables stop working. I tested this with a foreach loop through $_SESSION and it prints when INCLUDING the page, but doesn’t on redirect.

I’m kinda pulling my hair out over this because I really do need to use session variables after redirects.

File Structure:

index.php = submits login form => login_code.php = redirects after setting session vars => user_dash.php echos vars and nothing shows (empty vars, if statement to echo if isset)

I have removed the redirects and even simple hyperlinks aren’t carrying my session variables to the next page.

Live HTTP Header:

*serverinfo*/login_code.php

POST *serverinfo*/login_code.php HTTP/1.1
Host: server
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Referer: *serverinfo*
Cookie: PHPSESSID=im7kid3isj1q9ft03a68s6d5i3
Content-Type: application/x-www-form-urlencoded
Content-Length: 29
username=user&password=pass
HTTP/1.1 200 OK
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Type: text/html
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Server: Microsoft-IIS/7.5
X-Powered-By: PHP/5.3.10, ASP.NET
Date: Thu, 03 May 2012 16:24:54 GMT
Content-Length: 159
----------------------------------------------------------
*serverinfo*/content/admin_dash.php

GET *serverinfo*/content/admin_dash.php HTTP/1.1
Host: server
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Cookie: PHPSESSID=im7kid3isj1q9ft03a68s6d5i3

HTTP/1.1 200 OK
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Type: text/html
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Server: Microsoft-IIS/7.5
X-Powered-By: PHP/5.3.10, ASP.NET
Date: Thu, 03 May 2012 16:24:54 GMT
Content-Length: 3474
  • 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-03T01:23:02+00:00Added an answer on June 3, 2026 at 1:23 am

    You need to debug your application.

    It could be a surprise for you, but debugging takes most of the programmers time. So, time to learn some of the real programmers job.

    header("Location:./content/user_dash.php?".session_name()."=".session_id());
    

    used along with session_write_close() is a most bulletproof way

    if it’s still not working start debugging it.

    • check the session file
    • check the cookies
    • check ini settings
    • check session id in the user_dash.php – is it the same?
    • check if you really lose all your session or may be just one variable

    thank you for the ini settings.
    I can see 2 suspicious ones

    • session.use_only_cookies On means sending SID via url will have no effect. check session cookies AGAIN
    • session.cache_expire 180 180 is way too small.

    and I may overlooked some as I got not paid for the debugging your app and I have my own job to be done.
    So, I’d just suggest to make all settings default and never touch them until you got to know what are you doing certainly

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

Sidebar

Related Questions

how can i get all the SESSION variables in a particular php page?
I'm aware that you can get session variables using request.session['variable_name'] , but there doesn't
I can get the current selected row in this way: private void DataGridView1_CellContentClick(object sender,
I can get the unique id like className@2345 of my object by calling its
we can get google's hot trends based on location. is it possible to extract
Can get all triples with value null in specific field? All people with date_of_birth
You can get underground processes by ps ux I am searching a way to
You can get a list of databases using PRAGMA database_list or a list of
I can get the the first row in a ListView item in .NET 3.5
I can get the word under the cursor with or , and I can

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.