Private cookies and Google searches (2 different subjects)

Workarounds and usability notes.

Private cookies and Google searches (2 different subjects)

Postby John Robin Dove » Sun Mar 07, 2021 11:17 am

Hi Clifton,
Just a couple of things when you have time. I've converted all my cookies to private cookies which is fine. I don't have to encrypt anything now. But there is one problem. You may remember that one part of my program operates in a separate popup window. It seems that this part cannot use private cookies. Could you confirm this please and could you also confirm that a session cookie ceases to exist when the window that created it is closed.
Thanks
John

PS I have another question concerning your post of Sun Mar 17, 2019 5:27 am (page 3) https://www.pgsoftwaretools.com/forum/viewtopic.php?f=2&t=287&p=1097&hilit=Google+searches#p1097
You wrote that I could use Google searches using these settings url = "https://google.com/search?igu=1" or url = "https://www.google.com/webhp?igu=1" I must confess I never got round to trying this and forgot it. Well not quite because I was able to find it again. I think it would be very useful to me. I've just looked at a Google search address and it's considerably longer. Am I to understand that I should replace the 1 in your examples with the complete string of characters after the q as in https://www.google.com/search?q=badger&oq=badger&aqs=chrome..69i57j35i19i39j0j0i131i433j0l3j0i131i433j0l2.1710j0j15&sourceid=chrome&ie=UTF-8 Sorry for being a bit dense. I've been writing javascript non-stop since this morning.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: Private cookies and Google searches (2 different subject

Postby Clifton » Sun Mar 07, 2021 1:26 pm

Private cookies always are saved in the mainWindow, even when set in a popup. However, you should test your specific usage by setting one, then opening your dialog window and attempting to read in the previously set private cookie. The idea of private cookies is that they are always stored in the parent or main window and accessible by windows the are child windows of the parent. But like session cookies, they are destroyed when the parent or main window application is closed.

Regarding embedding google searches, the "q=[search string]" is fine, but you must also include the paramter "igu=1" or the search may not work as expected in a popup or embedded window/iframe via pgGotoURL().
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Private cookies and Google searches (2 different subject

Postby John Robin Dove » Mon Mar 08, 2021 8:20 am

Thanks for your reply. I was a bit confused about Google searches. I had an idea that you could access a page differently via Google Search in way that allowed it to be embedded in an iframe. Maybe I was thinking about Google Images Search. But a Google search is just a list of URLs right? In any case it seems Google searches cannot be embedded in an iframe. So actually they're not particularly useful after all.

I use this technique: when the user chooses to include a web page in an exercise I load the page into an iframe and a popup simultaneously to determine whether an iframe can be used or not. This picture shows the result for a picture accessed via Google Images.
Image
The picture below shows the result for a Wikipedia page. It seems all Wikipedia pages can be embedded in an iframe.
Image
I have recently had to modify the system to deal with security restrictions. The popup window loads faster than the iframe but the iframe takes the focus away from the popup sending it underneath. I got round this by adding a delay before loading the popup but that no longer works because now the delay triggers the popup blocker. It is not possible to refocus the popup because that's not allowed. However if I reload the popup after a delay using the same URL the blocker is not triggered and the popup comes to the top again. Somewhat clunky!

About cookies. I don't know whether what I want to do is possible. All the 'pages' of my app are displayed in an iframe via pgGotoURL. They all communicate with one another via private cookes When a URL cannot be embedded I open two popup windows that fill the screen. The first window contains a part of my program and the URL is displayed in the second. The problem is that the first window cannot read the private cookies and it cannot send cookies to the main app in the tab. For the time being I use ordinary cookies for the part of the program in the popup and private cookies for all the other parts of the program in the browser tab. This works well but I like the idea of private cookies because they work even when the user blocks cookies.
John
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: Private cookies and Google searches (2 different subject

Postby Clifton » Mon Mar 08, 2021 8:46 am

You might be able to fix the popup stacking issue by calling to open the popup, then have the mainWindow set a timer for say a couple of seconds or so then execute a [popupWindow].focus() command. Try this:
    var myPopup = tbfunction_pgGotoURL( . . . );
    setTimeout( function() { myPopup.focus(); }, 2500);
Regarding the embedded search, did you try igu=1 in the parameter list? Maybe that is no longer suppported, but it used to be. That was why it was supported by Google; so their search could be embedded in an iframe. I admin I haven't tried it in a while.

My typing application uses private cookies throughout, but in every case I'm just passing them from an iframe in a popup window, and not opening any new tabs. What you are doing should work, but you need to recognize that as soon as you open a new tab, the mechanism for getting and sending information is based on the browser using "postmessage" and then the calling window waits for response while doing other things. So to make this work in a "tab," you would have to send a request to the main window to get the data you need (private cookie in this case) and then the receiving window (the mainWindow) would have to send the information back using postmessage. This type of send/receive would require that you write your own receiving scripts on one or both ends to get two way communication to work.

Of course, normal AND session cookies should work without as much coding. Local storage cookies should work too. I think I would just use normal cookies if you can't get postmessage communication to work and if the data is not that sensitive to your program.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Private cookies and Google searches (2 different subject

Postby John Robin Dove » Mon Mar 08, 2021 10:54 am

I tried the google search with and without igu=1 or is it gui=1? Anyway neither made any difference. The search results page could not be embedded.

I haven't tried your suggestion for the popup today but I'm pretty certain it won't work because I've tried it before. It used to work but I think the restrictions have changed. So I'll settle for my clunky alternative for the time being. I think I'll also stick with the ordinary cookies. They only contain instructions for the program no personal names etc.

One other thing I tried but failed to do was make a system to prevent two instances of the program being opened simultaneously. This causes both to malfunction. I tried to do it with a cookie but that stopped the user reloading the page which might be a legitimate and necessary thing to do if something else went wrong. I don't know if it's possible. Probably not.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 3 guests

cron