Tuesday, 7 August 2012

User not logged in PHP when requesting from flash etc. because of invalid session.

This is way to set a session ID. Remember to call session_id before session_start. This is helpful for common issue when request from flash uploader (uploadify etc.) causes errors, because requested PHP file doesn'y knows that user is logged (see flash request as new, non-logged user).if ( isset( $_POST['sessionid'] ) ) { session_id( $_POST['sessionid'] ); } session_start();Remember that you must set sessionid on POST (or GET) request. This is useful when you connect to php page from other source than web browser (especially flash upload for example). You can pass your session ID to flash object 'flashvars' and when reqiesting upload or other page from SWF you can post/get session variable to access the same session normal web browser request has and for example be logged as current user.

No comments:

Post a Comment