Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8460927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:44:21+00:00 2026-06-10T13:44:21+00:00

In my server, a Symfony2 application is running. Moreover, the server has a folder

  • 0

In my server, a Symfony2 application is running.

Moreover, the server has a folder where some PHP classes are put. These classes are used for utility purposes and are used by http calls (in particular by using AJAX from the pages of my website). For instance, a PHP class is used for file upload (see next figure).

The schema of the current use of the php utility classes

The http call should be done by one of my webpage (and everything would be ok), but it could also be done from an external website. The latter http request is supposed to be a malicious one.

Hence, I need to insert such a code in the php class to check if the user is logged in (even not is it has a specific role). How to do that by considering that I’m using Symfony2?

PS: I underline that the control must be done in a generic PHP classes, not in a Symfony2 controller!

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T13:44:22+00:00Added an answer on June 10, 2026 at 1:44 pm

    I tried to use common PHP solutions, like setting a Session variable as suggested by Stony, however there is something in Symfony2 session that I’m missing. Even if a variable is defined in a Symfony2 controller, the $_SESSION object seems not to include it.

    Hence, I tried to follow the “controller way“, as suggested by Stony.

    Here follows what I did. Suppose to have to run the PHP class “FileUpload.php” through an http call. The PHP file has the class FileUpload to be used. In my case, the call was done through AJAX. Hence, I should do something like:

    <script>
      load('http://path/to/fileupload.php')
    <script>
    

    where load() is an hyphotetical Javascript function for AJAX calls.

    Of course, the initial idea was to include all the controls in FileUpload.php. I wan’t able! So what?

    Simply, create a controller in Symfony2. Then create your action. E.g.

    public function fileUploadAction(){
        //control if user is logged and has required role as usual with Symfony2
        $uploader = new \Path\To\\FileUpload();
        //do something with object uploader
    
        exit(0);//Symfony will not require an answer, but you did what you needed
    }
    

    Of course, the script in the webpage has to be updated:

    <script>
      load("{{path('route_to_fileUploadAction')}}")
    <script>
    

    Remember to put the FileUpload.php in a secured folder.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I deployed a Symfony2 application on my server and I wanted to disable some
I have managed to successfully deploy my Symfony2 application to a production web server,
Trying to install Symfony 1.4.11 application on Ubutnu Server + Nginx + php-fpm Nginx
I am working on an application (Symfony 1.4 / Doctrine) that has some pages
I have a PHP application that currently has 5k users and will keep increasing
In Symfony2, when accessing my application locally via app_dev.php, everything works fine. However, when
I'm using the build-in SOAP-Server within a symfony2 application and beside handling the StdClass-Object,
I am currently developing a system on a server running PHP version 5.1.6 thus
I uploaded my symfony2 project to server grove. The main page loads, but all
I want to deploy 2 Symfony2 projects onto an EC2 server. In addition I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.