HybridAuth not authenticating when using custom php session path
Asked Answered
K

3

17

I have an issue when using the HybridAuth plugin. I have included the plugin as a popup in in my home page. When clicking on the login button from home page the plugin will load in colorbox.

In my server I can't use default php session save path so that I have set it as php temp path for saving session like below in index.php of my root folder.

$dir = sys_get_temp_dir();
session_save_path($dir);

After updating this code, the plugin is authenticating the social media that customer selecting successfully and return back to my site, but it is not passing the below condition,

$hybridauth->isConnectedWith( $_GET["connected_with"] ) // it is always return false

In second case I have updated the session save path in index.php of plugin folder also, but at at that time in the login popup instead of showing login UI it is directly showing an error page like below

"You cannot access this page directly."

Any help would be appreciated. Thanks in advance.

Korry answered 4/7, 2014 at 7:1 Comment(4)
I'm also getting same error. Can anyone provide a quick fix for this?Noncooperation
@user2916075: May be it's not storing the user session which you tried to login. Did you check whether the session exists after redirecting to your site?Prissie
Turn on debugging and give us a chance to see what the API is saying the problem is. I'm willing to bet you'll see PHP session.name diff from default PHPSESSID.Bestrew
what this error message means?Reames
B
2

The problem is your default session path:

$dir = sys_get_temp_dir();
session_save_path($dir);

I would print_r sessions to see what got registered. Why do you have issues with default session path? I wouldn't try to alter it and make sure that works first. This is altering the main functionality of HybridAuth.

Why can't you use the default php session save path? are you on a shared host?

--

If you have shell access make sure the web server user has write access to the directory; that should take care of the issue.

Baumgardner answered 16/9, 2014 at 5:22 Comment(0)
D
1

As often : RTM and discover the use of isConnectedWith

isConnectedWith() Return a true or false if the current user is connected to a given provider. Hybrid_Auth::isConnectedWith() use PHP Sessions. To know more refer to the HybridAuth Sessions section.

Hybrid_Auth::isConnectedWith(provider)

Where provider is the name of the tested service. eg : Hybrid_Auth::isConnectedWith('Twitter')

Be sure that your $_GET returns the good service name.

If you want a list of connected providers : Hybrid_Auth::getConnectedProviders()

If you want to inspect session's datas : Hybrid_Auth::getSessionData()

API !

Delastre answered 14/7, 2014 at 9:48 Comment(0)
D
0

Add your 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.

Dinitrobenzene answered 9/2, 2017 at 10:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.