10354

User not recognized through Parse\\ParseUser, but exists in $_SESSION

Question:

I'm currently writing a site built in PHP using Parse.com to store the site's data. I've used parse in several projects before and some of the features fit extremely well. I've now run into an issue where a logged in user can't be detected properly.

<?php use Parse\ParseClient; use Parse\ParseObject; use Parse\ParseQuery; use Parse\ParseGeoPoint; use Parse\ParseUser; ParseClient::initialize('Omitted', 'Omitted', 'Omitted'); (... truncated) function get_user(){ //BROKEN. //TODO: Fix $currentUser = ParseUser::getCurrentUser(); if ($currentUser) { return $currentUser->getObjectId(); } else { return false; } } (... truncated) ?>

This code is only marginally modified from that in the PHP examples given by parse, but seems to return false no matter what the state of "Logged In"

Session start is called to ensure the session is running, and calling print_r($_SESSION) outputs a dump which includes the relevant user object.

I understand it's likely something silly that I've missed, but any pointers in the right direction would be much appreciated.

Answer1:

For reference here - I was using a dedicated windows server that was configured in a somewhat non-standard way. We've since migrated from the windows server, because Windows - and also a barrage of unrelated issues meant it was just easier to use CentOS instead.

This problem was solved by explicitly calling parse's session storage setter - ParseClient::setStorage( new ParseSessionStorage() );

This was unexpected as the $_SESSION global did contain the relevant info - but parse wouldn't pick this up until the session storage was set.

Recommend

  • ParseQuery - Properly handling IndexOutOfBoundsException - Parse.com?
  • How to Print JSON Array returned from controller class to jsp page
  • ParseUser Username Adapter in Android ListView doesn't show Data
  • Dismissing Modal View Controller causing layout problems
  • error: cannot access Task class file for bolts
  • How to solve the jshint error `Don't make functions within a loop.` with jquery $.grep
  • getting bad request while using passport in login form
  • How to have NHibernate persist a String.Empty property value as NULL
  • FFTW advanced layout — inembed=n and inembed=NULL give different results?
  • Class works not correct. How to make it better?
  • Entity Framework 6 connection string dll app config
  • VerifyInputWhenFocusTarget property has no effect
  • Error authenticating using LinkedIn iOS SDK
  • Set audio input level using portaudio
  • Angular2 How to display localStorage value inside HTML5 template?
  • how do you read the ramda docs?
  • Any function in numpy/pandas/python to search and replace
  • Timer is not working in separate class in C#
  • TypeError: Main.login is not a function
  • How can integers (keys & values) be added and retrieved from a NSDictionary
  • wxWidgets: Detecting click event on custom controls
  • how can I key rotate for google cloud storage service account?
  • nhibernate queries SubQueryExpression
  • Is it possible to send skype chat messages from a linux server without X?
  • Using an STL Iterator without initialising it
  • Fragment gives me an error while inflating 1
  • Unix Network Programming Clarification
  • Google map in top corner left
  • Correct implementation of List Iterator methods
  • How can I mock ui-router's resolve values when testing a state's configuration?
  • Android activity accessing service's static reference before the service is ready
  • Bug in WPF DataGrid
  • TFS: Get latest causes slow project reloading
  • Javascript Callbacks with Object constructor
  • Trying to switch camera back to front but getting exception
  • How to make Safari send if-modified-since header?
  • Binding checkboxes to object values in AngularJs
  • Net Present Value in Excel for Grouped Recurring CF
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?