Facebook PHP SDK 4: FacebookJavaScriptLoginHelper Issue - facebook-php-sdk

Im using the FacebookJavaScriptLoginHelper method to get the session (Im logged with Javascript API) but is not working fine. I need to reload the page to get the data.
And it seems like after a while the session expires and I need to reload the page again to get the session.
Any hint?
Thanks in advance!

When using the JavaScript SDK, the cookie is set after the user has logged in, which is inaccessible to the PHP code since it was set after the PHP code was loaded. The PHP script needs to be re-loaded after the JS SDK has set the cookie.
This is the way JavaScript and PHP behave together, as PHP is server-side and rendered before the JavaScript code (which is client-side) has executed.

Related

How can I embed Superset Apache charts in my application bypassing login

I have been running into an issue where I modified "PUBLIC_ROLE_LIKE_GAMMA = True" in both superset/config.py and added the datasource to PUBLIC as per the link suggested reference in google.
But I'm still getting the AUTH login page while accessing the iframe.
At my work we had the same problem, we wanted to embed iframes on a web app and we kept running into the same issue. We really wanted to bypass it, so we implemented a custom security manager for it. If you're not afraid of modifying superset's code, you could take it as an inspiration; here's the fork. The modifications and how to use them are explained in the fork's README file. If you take a look you will see that not many files are needed to be modified in order to implement this!
Basically we delegated the login responsability to the web app, by recieving a token from it and passing it to an api that knows the web app's login policy. In the fork there's a mock of how an api would do such thing. When recieving data of a web app's user that isn't registered in Superset, we simply create the user for them with the info and log them in.
Afterwards the iframe looked like this, since we had a simple case, where a default welcome chart was all that was needed to be displayed:
<iframe
width="600"
height="400"
seamless
frameBorder="0"
src="http://<superset-endpoint>/login?token=a"
>
Public dashboards
This is not meant for production. It’s for experiments or while doing a proof of concept.
#superset_config.py
PUBLIC_ROLE_LIKE_GAMMA = True
After this, we need to re-run the init user (if already run)
docker-compose exec superset superset-init
please see: https://sairamkrish.medium.com/apache-superset-custom-authentication-and-integrate-with-other-micro-services-8217956273c1

Website needs force refresh after deploy

After deploying a new version of a website the browser loads everything from its cache from the old webpage until a force refresh is done. Images are old, cookies are old, and some AJAX parts are not working.
How should I proceed to serve the users with the latest version of the page after deploy?
The webpage is an ASP.Net webpage using IIS7+.
You can append a variable to the end of each of your resources that changes with each deploy. For example you can name your stylesheets:
styles.css?id=1
with the id changing each time.
This will force the browser to download the new version as it cannot find it in its cache.
For ASP.NET you can use the cache control and expires headers. You can also set up similar headers in IIS 7 for your images. If you have any other cookies you can expire them manually.
I have not tried it, but it looks like you can do an ever better job of bulk setting cache control in IIS 7. See this thread and this link. At that point you are only left with unsetting any custom cookies you have (which you won't be able to control with HTTP cache control settings).
I don't know of any method to "unset everything all at once" easily.
You could use http headers to control the cache of your clients.
I'll just leave this here for you. http://support.microsoft.com/kb/234067

File Uploading without page refresh in Web pages

Hii,
Any one knows how to upload files to the physical location of the server. It is possible using file upload control that i know. But i want to avoid the external postbacking of the page. For e.g exactly like what in the yahoo mail did.
In yahoo mail latest version if you attach a file that won't post back and attach that file in to server. What is the technology behind that?
Normally when you submit a form it does a POST request to the server, causing a refresh. Ajax requests get round this by using JavaScript to send the POST data through to the server, and that doesn't need a page refresh.
Ajax requests can't be used to send file data though, so the best way to currently do it is with an iframe hack - you use JavaScript to dynamically build up a form within an iframe, submit that form via JavaScript, and listen for the iframe's onload event. So you know when the form has been submitted. A version of this approach is detailed here:
http://www.webtoolkit.info/ajax-file-upload.html
Other methods to do this would include using a Flash-based solution like http://www.swfupload.org/ or a wrapper like http://www.plupload.com/ - these will prevent you having to roll your own solution and will also provide some extra functionality - upload progress feedback, for example.

Cache: How to exempt just one block

I've got a Drupal 6.x install, and there is one block generated by the Station module which displays the name of the show currently playing. Is there a way to make just that block exempt from caching? Alternatively, can I insert a 'refresh' for only that block at 00:59:00 ?
I'm not a php guy, but have found the place in the module where this block is generated, and think I can make the change if I new what to do.
If the block is a Javascript or jQuery widget the cache wouldn't bother you. eg: The page content is cached but runs a client side script that calls back to the server for the latest info and does an ajax thingy.
Alternatively, you could turn page cache off and set cache for some of the queries/element on that page. But if you're not a PHP guy that might be a struggle.
See:
http://api.drupal.org/api/function/cache_set/6
I'm sure there are other options people will help you with.

Authentication Signout and back button asp .net

I have a problem in my asp.net pages
We are using form authentication. Once page is signed out I am able to go back to the previous page. This is due to pages cached in browser.
So i disabled the cache. But this has its own drawbacks.
If user is logged in he will not be able to navigate to the previous page using back button since no cache available in the browser.
if I have a file download in the page it wont work since cache disabled.
Even history.back javascript function also not the correct solution.
What is a permanent solution for this problem? I have faced with this all the time and never found a consistent solution.
Can anyone suggest a possible solution for this?
Thanks
SNA
You shouldn't need to disable caching. If you invalidate their session or authticket, you should be able to detect if they are signed out or not, in which case you can redirect them. This link may be helpful. If you are really concerned with the back button try using clearing the clients history via javascript after you log them out.
EDIT
Check out This Link It goes in depth on some of the different approaches. I don't think there is a sure fire way of keeping users from looking at previously downloaded content, but there are a few things you can do to make it difficult.

Resources