Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed cookie binding to session #14649

Merged
merged 11 commits into from
Jan 5, 2020
Merged

Conversation

ekmst
Copy link
Contributor

@ekmst ekmst commented Dec 23, 2019

Hello!

In raising this pull request, I confirm the following:

  • I have read and understood the Contributing Guidelines
  • I have checked that another pull request for this purpose does not exist
  • I wrote some tests for this PR
  • I have updated the relevant CHANGELOG
  • I have created a PR for the documentation about this change

Small description of change:
Removed cookie binding to session
Phalcon\Http\Cookie no longer depends on the session service and data will not be duplicated in the session. This made it difficult to use cookies in stateless applications (SPA).

Thanks

@niden
Copy link
Sponsor Member

niden commented Dec 23, 2019

@ekmst can you rebase and send this to the 4.1.x branch please?

@niden niden added 4.1 enhancement Enhancement to the framework documentation Documentation required labels Dec 23, 2019
@ekmst ekmst changed the base branch from 4.0.x to 4.1.x December 23, 2019 19:23
Copy link
Contributor

@sergeyklay sergeyklay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not opposed to this change, but I would like to see a more detailed description of these changes. Not just "fixed issue XXX". What suggested in return? Does it breaks backward compatibility? If so, what are workarounds? Why can't we go further with this?

Regarding change log: why you put these changes in the "Changed" but not in the "Removed" section? Also move please this to the 4.1.x version in the change log.

@codecov
Copy link

codecov bot commented Dec 23, 2019

Codecov Report

Merging #14649 into 4.1.x will increase coverage by 0.11%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##            4.1.x   #14649      +/-   ##
==========================================
+ Coverage   67.49%    67.6%   +0.11%     
==========================================
  Files         483      483              
  Lines      111403   111414      +11     
==========================================
+ Hits        75192    75324     +132     
+ Misses      36211    36090     -121

@niden
Copy link
Sponsor Member

niden commented Dec 23, 2019

This will definitely break BC not by means of interfaces but by functionality itself. For instance right now I set my cookies and I know they will go in the session. With this change they will not so I will need to write that code myself.

There are plans to completely rewrite the HTTP layer and offer cookie management with different storage engines i.e. files, session etc. but we are not there yet.

@ruudboon @sergeyklay Thoughts on this? If we are to use this we will need to introduce also some sort of a storage i.e. take the session storage from where it was (see this PR) and put it somewhere else so that people can use it at least for now.

@ekmst
Copy link
Contributor Author

ekmst commented Dec 23, 2019

I am currently developing a SPA application where sessions are not used at all. But I need to work with cookies. But since the session is not used, I get errors that the session service was not found. And now I have to use a stub to avoid this.

I do not quite understand why cookies are also stored in sessions?

@niden
Copy link
Sponsor Member

niden commented Dec 23, 2019

@ekmst storing cookies in files or the session are the most common storage engines.

This code is really ancient and has never seen much love - we just let it be. Definitely needs to be reworked so what you did I would say is step 1 and we need step 2 to at least have the option to store the cookies in the session (current functionality)

I will see what I can come up with in the next few days and will ping you so that we can align efforts.

@ekmst
Copy link
Contributor Author

ekmst commented Jan 4, 2020

@niden
Can we save cookies in the session only if the session service is defined in the DI container? If the session service is not defined, then we work with cookies and we will not throw an exception.

Or we can enter a flag to explicitly indicate that you want to save cookies in the session.

@niden
Copy link
Sponsor Member

niden commented Jan 4, 2020

@niden
Can we save cookies in the session only if the session service is defined in the DI container? If the session service is not defined, then we work with cookies and we will not throw an exception.

Or we can enter a flag to explicitly indicate that you want to save cookies in the session.

That is actually a great idea. If we mention this in the documentation it should be fine and most people would not be affected if they already have the session service registered.

@ekmst can you make the adjustments?

The above will definitely help and give us time until we redesign the http layer.

@ekmst
Copy link
Contributor Author

ekmst commented Jan 4, 2020

@niden
Yes, I will try to do it soon.

@niden niden added 4.0.1 and removed 4.1.0 labels Jan 4, 2020
@niden niden added 4.1.0 and removed 4.0.1 labels Jan 4, 2020
@niden
Copy link
Sponsor Member

niden commented Jan 4, 2020

@ekmst looking good so far. Once you are done make sure the changelog is updated and ping me so that I can merge this

@ekmst
Copy link
Contributor Author

ekmst commented Jan 4, 2020

@niden

Done

@ruudboon
Copy link
Member

ruudboon commented Jan 4, 2020

With these changes I wouldn't mind to push this into 4.0.x. Don't think we're breaking anything
Thnx ekmst

@niden
Copy link
Sponsor Member

niden commented Jan 5, 2020

With these changes I wouldn't mind to push this into 4.0.x. Don't think we're breaking anything
Thnx ekmst

We will have to cherry pick them because this is a different branch. We can talk about this in TG.

@niden niden merged commit 7964658 into phalcon:4.1.x Jan 5, 2020
@niden
Copy link
Sponsor Member

niden commented Jan 5, 2020

Thank you @ekmst

@ekmst ekmst deleted the cookie-without-session branch January 5, 2020 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Documentation required enhancement Enhancement to the framework
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants