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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:56:38+00:00 2026-05-26T15:56:38+00:00

I am currently writing an Edit Account module. Using jQuery.post(); I can successfully update

  • 0

I am currently writing an “Edit Account” module. Using jQuery.post(); I can successfully update my database, and I can write to the session variables from the PHP script – however,
when trying to access the Session variable that I just wrote to, the data does not seem to have been updated.

I write to the session like this: $_SESSION['email'] = 'john@doe.com'; in my Ajax.php

My jQuery (minified) callback on success:

$.post(...,function(res)
{
  if(res=='success')
  {
    // Alert the new E-Mail, read from the Session!
    alert("<?php echo $_SESSION['email']; ?>"); 
  }
}

However, the alert does not output john@doe.com, it outputs whatever the E-Mail was it was when the entire page was loaded. When I refresh the page, the session data has been properly updated.

I do have session_start(); on both index.php (my site) and in Ajax.php

If you need more info please do let me know. 🙂

  • 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-26T15:56:38+00:00Added an answer on May 26, 2026 at 3:56 pm

    First of all it should be

    alert("<?php echo $_SESSION['email']; ?>");

    and secondly $.post is dynamic but <?php echo $_SESSION['email']; ?> is static. It renders once, on load, not everytime you make an .post() so if

    $_SESSION['email'] = 'blah'; by the time the page is loaded, the alert will always be alert("blah"); , until you reload the page.

    If you want to alert the new session variable you have to make a new ajax request to a php file (ie. return_session.php?key=email ), that will return the new session variable

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

Sidebar

Related Questions

I'm writing a simple DNN module - using DNN 5.6.1 and currently just working
I'm currently writing a couple of MVC sites using Kohana as my framework. Each
I'm currently writing a small python app that embeds cherrypy and django using py2app.
I'm currently writing an edit-in-place script for MooTools and I'm a little stumped as
I am currently writing a little bootstrap code for a service that can be
I am currently writing an web application where you need to log in, using
I'm currently writing DataTemplate for my custom type lets say FootballPlayer. In this template
I am currently writing an application which I plan to sell as SaaS. Without
I'm currently writing a paper for my company, about how to avoid calling the
I'm currently writing an application that allows one to store images, and then tag

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.