Jump to content

Arrays between php scripts?


greenheart

Recommended Posts

Hello I have an array of data in one script on my html/php page. I want to call up this array of data in another php script later down the page, is this possible?

 

The reason for this is because I have the content on my page in tabs, and each tab has a separate php script in it and you can't have one long php script it has to be a single one for each tab.

 

The tabs are AJAX so that they all load in the background at once. The tab thing isn't that important to mention I thought I would justify why I want an answer to this question...

 

Thanks for any help.

Link to comment
Share on other sites

Just so you're clear, AJAX doesn't load things "all at once." AJAX uses HTTP and loads things on demand. AJAX is stateless, like all HTTP requests.

 

If you have an array and you want to get access to it again, the simplest way would be to save it in a session variable if you're using sessions.

 

You could save it into a cookie but it would be very easy for the user to manipulate.

 

You could save it into a database, but since you need a way to identify the user this wouldn't be much better than just using a session.

Link to comment
Share on other sites

Thanks for the reply, how would I use session variables to achieve this?

 

The data is the same for every user (for the time being) so I could save it into a database also you say?

 

I'm also trying to figure out caching too, if that can be done in a database maybe I should go the database route?

 

Thanks for much.

Link to comment
Share on other sites

not too sure a session will work with AJAX but I guess it could but I never used a session with an ajax request so I wouldn't know but alot of problems on here  have to do with AJAX and session problems.. so if I were you I'd go with the database idea :)

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

not too sure a session will work with AJAX but I guess it could but I never used a session with an ajax request so I wouldn't know but alot of problems on here  have to do with AJAX and session problems.. so if I were you I'd go with the database idea :)

 

I don't have any problems with AJAX and sessions. AJAX sends the exact same HTTP request as a regular webpage load including cookies etc. so using start_session() gets you access to the user's session just as it would a regular HTTP request.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.