1

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

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

8 Comments

Well, what I actually want is to store data that I get in php (trough shell_exec) and save it in $_SESSION array and display in other tabs. Is this possible?
i am not sure about the relevance of shell_exec here , prolly you can share your code?
Well, I wan to do something as simple as this: $_SESSION[mac]=shell_exec('ifconfig | awk '/eth0/ {print $5}' '); and then use this variable for something in other tabs.
well sure .. i can not guarantee if you would get any output from your shell_exec command, but if you do it should save perfectly in the session var and should be accessible in other tabs. If you are having issues make sure your shell_exec command returns valid output. Also make sure all tab scripts have session_start at the top of the script.
I know, I just wrote that from my head, syntax is definitely wrong :) But I was just wondering will this work just by using session_start() on in every php file. How is than session identified for different users?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.