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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:48:23+00:00 2026-05-13T18:48:23+00:00

I have instantiated a class in my index.php file. But then I use jQuery

  • 0

I have instantiated a class in my index.php file. But then I use jQuery Ajax to call some PHP files, but they can’t use my object that I created in the index.php file.

How can I make it work? Because I don´t want to create new objects, because the one I created holds all the property values I want to use.

  • 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-13T18:48:24+00:00Added an answer on May 13, 2026 at 6:48 pm

    Use the session to save the object for the next page load.

    // Create a new object
    $object = new stdClass();
    $object->value = 'something';
    $object->other_value = 'something else';
    
    // Start the session
    session_start();
    
    // Save the object in the user's session
    $_SESSION['object'] = $object;
    

    Then in the next page that loads from AJAX

    // Start the session saved from last time
    session_start();
    
    // Get the object out
    $object = $_SESSION['object'];
    
    // Prints "something"
    print $object->value;
    

    By using the PHP sessions you can save data across many pages for a certain user. For example, maybe each user has a shopping cart object that contains a list of items they want to buy. Since you are storing that data in THAT USERS session only – each user can have their own shopping cart object that is saved on each page!

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

Sidebar

Related Questions

Suppose that we have previously instantiated three objects A, B, C from class D
I have a C++ template class that gets instantiated with 3 different type parameters.
I have a Class A that when it is instantiated and saved for the
I have a class that is a singleton. This singleton is instantiated using GCD
Let's say we have a concrete class Apple . (Apple objects can be instantiated.)
I have multiple Controller objects that either execute some script and then redirect to
So in my .h file I have template <class T> void getValue(T *val, int
I have a user define class inside my zend application(as default) application/library/Custom_/Custom_Test.php I want
I'm trying to use a ClasspathResourceLoader for loading my *.vm files. I have them
I have a initApp.as which instantiates a class which needs to access the currentState

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.