My problem is simple.
I have two users on two different devices accessing the same servers pages (page 1 and page 2 respectively ).
I want to use php forms in one page to change the second users page.
(i.e. 1st user on page 1 presses a button and changes the image on 2nd users page 2 , on a separate device).
I thought I could do it by using the 2nd users session ID in the form on the 1st persons page, and fool the server to reload the 2nd users page with the updated info.
But i can see no example of it anywhere on the web. Is this possible or should I just use Ajax?
Thanks for any help.
I would suggest not hacking Session ID's like that, they're meant to identify a single user.
If you want data shared between users it's likely you'll be well served using a database, such as MySQL as commonly runs along PHP.
Related
I am trying to get unique page views like if the page is already visited it should not be counted.
So the solution I thought was like on each reload save the page path to a localStorage in an array and on next reload check if the page path already exists in the localStorage array dont increment else increment the count by 1. If there are 500 pages in website then we need to store all 500 page path in localStorage which would be high is what I felt. This is the scenario when the user opens all the 500 pages of the website
The requirement is we need to get all this data and send it along with form submission to a third party server.
Any better solutions?
Doing this client-side is sub-optimal. I suggest doing this on your server, based on IP and using a cookie on the client to track unique clients, so that you can evaluate which pages they have viewed etc.
If you absolutely have to do this client-side, using localStorage might be slower and/or problematic due to limitations. You could look into indexedDB, as well.
I have a problem, I am writing a system for an company and I want it to be as secure & robust as possible, but now I'm stuck.
I have a product list, where a logged-in employee can edit, delete or emit (print) specifications about a product.
Let's assume I'm a logged-in employee on that system. When I click a product from the product list and then click on emit (print), javascript will send data over POST to the next page (Yes, it must be JS, because of the design of the page).
So the next page is displayed with correct info about that product (because POST passed the product id to the next page, which then realized an SQL query and fetched all info).
Now, on that page, I can verify if all info is correct and then click again on emit (print) to finally print the specifications. But here I came across a caveat: How will the next page know the product ID? I can't use POST, because there's nothing to post..
Cookies are designed for such stuff, but I think that when I'm logged in two tabs on the same browser and then click print on both tabs at once, the same Cookie will get called twice and overwritten twice (conflict), and, consequently, product id's could get swapped.
$_SESSION I believe I can't use too, because if two users are logged on the same Machine, data could get swapped too, just like in cookies.
Now, what is the 'best' practice to pass data between pages that "supports" multiple concurrent users on the same machine, and even in the same browser?
This somewhat similar question solved my problem:
Any way to identify browser tab in JavaScript?
This way I can create an unique "emitID" for that tab and then use that to take track of the current product id.
Also thanks to #SteevePitis for pointing me in the right direction.
In short, I had a scoreboard application written in HTML and Javascript that contained a timer, home name, guest name, home score, guest score, and period. I was able to make a display webpage without buttons (see image) and a controller webpage with buttons. Using Dropbox Datastores API, I was able to control the display webpage with the controller webpage. Now that the Datastores API is no longer working, I need a different way of syncing the variables across the webpages. Any thoughts on how I could do this? I was thinking about using a database.
If you only want to store the data for the current browser, I'd offer LocalStorage as a solution. Otherwise, yes, sending the data to a database is appropriate.
(I apologize for any incorrect lingo)
I am creating an internal web page as a sort of intranet for me and another associate to use in our department to keep track of information. I have created "pages" using HTML to navigate and saved in our department folder. Doesn't need to be flashy just functional.
I have a table with 5 columns of information for each item we need filled out. I have created a pop-up window and form for these 5 columns to open and the idea is that when the the user (me) fills the form out and clicks the submit button, the information is transferred to the parent page, saved and stored for later tracking.
I'm assuming this isn't possible by just saving .html files into our network folders. I think i might need a database to "save" the information the user filled out.
I wouldn't necessarily need the window pop-up..
Is this way over my head?
You would at least need a server side language such as PHP. Using a Database is highly recommended.
In my very humble opinion - Yes, it does sound as if this is over your head right now.
Recommended readings:
http://www.amazon.com/s/ref=nb_sb_ss_c_0_3?url=search-alias%3Dstripbooks&field-keywords=php&sprefix=php%2Caps%2C129
Let me know if my answer is helpful.
I want to develop a small javascript tool for browsers.
This tool can extract some content from current webpage and submit it to another site.
The whole work flow is divided into 3 stages.
The first stage is to extract content from current page.
The second stage is to log in. The user needs to enter their username and password in a login form.
The third stage is to submit the content abstracted from the first stage.
My problem is that the third stage needs the cookie from the second stage.
I have tried iframe, but failed.
Cookies need to be, at least, on the same top domain and the cookie set to be visible up to the top domain. If you are on another domain, this is not a viable option.
Another way you can pass data is via a form submit. Assuming you are on a page on a foreign domain, using this technique, you can have your script build a login form that submits to your site, along with the data you gathered. It also means the 2nd and 3rd step is merged. No cookies needed.