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 8353663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:19:39+00:00 2026-06-09T09:19:39+00:00

I have a Service class that stores an object into the session $this->session->set(‘utmUser’, $this->session->serialize($this->utmUser));

  • 0

I have a Service class that stores an object into the session

$this->session->set('utmUser', $this->session->serialize($this->utmUser));

And I get the unserialized object from the session:

$this->utmUser = $this->session->unserialize($this->session->get('utmUser'));

But the result is not an instance of the stored object.

The session contains this serialized string:

string(221) “a:2:{i:0;O:68:”Symfony\Component\HttpFoundation\SessionStorage\NativeSessionStorage”:1:{s:10:”*options”;a:5:{s:8:”lifetime”;i:0;s:4:”path”;s:1:”/”;s:6:”domain”;s:0:””;s:6:”secure”;b:0;s:8:”httponly”;b:0;}}i:1;s:2:”en”;}”

Setting all properties of the object as protected doesn’t work.
What am I doing wrong?

  • 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-09T09:19:40+00:00Added an answer on June 9, 2026 at 9:19 am

    session->serialize() and unserialize() do not do what you think they do, they do not serialize and unserialize an object, they serialize and unserialize the whole session. They do not take any parameters and in fact have been removed in Symfony 2.1

    You can just set the object into the session and Symfony will take care of serializing and unserializing it for you, just use:

    $this->session->set('utmUser', $this->utmUser);
    

    and

    $this->utmUser = $this->session->get('utmUser');
    

    In any case you may reconsider if you really need to store the whole object into the session. If this is a big object this can be very inefficient. If that is the case and the object is stored in a database, you can store just the id of the object and then reload it from the id when you need it.

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

Sidebar

Related Questions

I currently have service classes that look something like this public class UserService :
I have this code that describes a service: public class navigation_web extends Service {
I have A WCF service that has a class that inherits System.Web.Security.RoleProvider. In this
I have a service class that I need to execute a method on a
I have a wcf service. The service itself (class that inherits the ServiceContract )
I have created a service class for my network connection so that my app
I have a REST service and I want to have a helper class that
I have some class that I'm passing as a result of a service method,
i have a class that uses a proxy class inside to call a service
I have a POCO class that is mostly built through a service. I hit

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.