4

I am using HybridAuth social plugin in my website to login from facebook and other websites,

everything is working fine, but when I checked on other computers, there is an error:

You cannot access this page directly

and I noticed that the error comes when the browser use WWW in the address bar, the browser on same computer eg: opera not using the www so there is no error on those browser.

Please help me how can I fix this error so login can be done from any browser.

doru
  • 9,022
  • 2
  • 33
  • 43
Mani
  • 125
  • 5
  • 18
  • 2
    set your base_url properly like `"base_url" => "http://sample.com/hybridauth/"`, it may cause this error – Jothi Kannan Sep 06 '13 at 10:27
  • This came up after changing how i handle sessions. Started using Zebra Sessions and this started. Disabling Zebra Session makes it work. But sadly I need/want to keep Zebra Session as well as needing this! So I would check if anything changed on how you handle/store sessions. – Shawn Rebelo Nov 07 '14 at 19:41

5 Answers5

3

The reasen is because Facebook callback in different php-session and cant access config info from caller session. Look at Endpoint.php if ( ! $storage->config( "CONFIG" ) ) ... The rason was because I use in my site with 127.0.0.1 but return_uri was with localhost because of Facebook restrictions. PHP builds different sessions in this case.

Stephan
  • 46
  • 2
  • This answer seems to be what I'm looking for, but doesn't appear to detail the solution clearly enough. Can you confirm what needs to change in Endpoint.php? Thanks – goose Feb 16 '14 at 11:18
  • 1
    yes - having a consistent uri in the config, ie. using http : // www . SITE . com, in all the necessary locations solves my problem – my account_ram May 18 '14 at 21:46
2

adding "www." to the URL resolves the issue.

ashish1dev
  • 81
  • 1
  • 6
0

After adding this on top of my controller it started working

if (session_status() == PHP_SESSION_NONE) {
    @session_id($_COOKIE['CAKEPHP']);
    @session_start();
    @session_name('CAKEPHP');
}

Read here https://github.com/hybridauth/CakePHP-HybridAuth/pull/1

Subodh Ghulaxe
  • 18,333
  • 14
  • 83
  • 102
  • My website is not based on any standard MVC plugin. But we have similar structure . I was trying to write a plugin to connect with the facebook using Hybrid . But getting the same "You cannot access this page directly" error . Can you help how I can use your answer in my website ??. http://stackoverflow.com/questions/26750936/facebook-login-using-hybridauth-showing-error-you-cannot-access-this-page-direct its the link to my question – Vikram Anand Bhushan Nov 05 '14 at 06:35
0

Those who are facing error message "You cannot access this page directly."

Try after adding @session_start(); statement at the top of your files.

AnkitK
  • 388
  • 3
  • 10
0

This could be related by using a custom session handler which is set by session_set_save_handler(). I resolved this issue by adding our own custom session handler at the top of hybridauth/index.php (located in the same dir as config.php and live.php). This forces Hybrid Auth to use your custom session handler.

Edd
  • 683
  • 1
  • 11
  • 21