Jump to content

Using Session Vars in Controller


S.Frenzer

Recommended Posts

Hi,

 

I would like to know, how I can get access to the $_SESSION array in a controller, e.g. the OrderConfirmationController.php?

My tries say that the var _SESSION ist undefined. When I assign the session var to smarty, he says there is no index or property like that.

 

So please how can I use the session vars within a controller file?

 

Thanks a lot

 

Link to comment
Share on other sites

Actually I knowthat it's an "feature" by laravel not using the $_SESSION array.

But ther must be a solution to get access to it within a controller or not?

I've data in it and want to use them in the OrderConfirmationController.php. I tried some solutions I found in the web, but nothing works.

 

Some failed tries:

  • binding the session object from laravel over "use Session;"
  • binding the cookie object from laravel over "use Cookie;"
  • using the context object "Context"

but nothing runs.

 

Is there any idea, where is my mistake?

 

Thx

Link to comment
Share on other sites

Ok, I found my mistake.

For those who wants to know or maybe wants to deal with sessions:

There's no session_start() existing! The reason why my own datas will be stored in the session was, that I use ajax calls to do this.

In my server files of these calls I use session_start(), so at this time it will be created instead of using an existing one.

 

So the solution is to set a session_start() at the beginning.

 

The better way of course is to use the cookie context of presta/laraval, but for me it's working good using real sessions.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...