Newman
Newman

Reputation: 27

jquery ajax and php session

I have a simple web page that has 3 tabs in my main content area. Once a user clicks on a particular tab, I use jquery and ajax to fetch some data from server and (of course) without reloading everything I change some div below those three tabs.

I use $.post to get data from the server and there are 3 different php files on a server that I call (one for each tab) and get data from.

Is it possible to start a php session when a user clicks on the first tab and save some $_SESSION variables and then use them when a user clicks on the second or third tab so that I know what user clicked on the second or third tab?

Thanks! Newman

Upvotes: 1

Views: 1425

Answers (1)

Sabeen Malik
Sabeen Malik

Reputation: 10880

Yes, the sessions are shared across all php scripts. So whatever you save in the first tab will be readable on 2nd and 3rd tab. Keep in mind that

Edit: Thing to keep in mind here is that the domain should remain the same for all scripts to be able to see the session.

Upvotes: 1

Related Questions