Open daschl opened 12 years ago
Update:
okay, it looks like the identical names seem to be the root cause. Maybe we can raise an exception if this is not allowed?
I've been meaning to change the API to eliminate the ambiguity. What do you think: Session::<method>("configName.keyName.subKeyName", ...)
or Session::<method>("configName", "keyName.subKeyName", ...)
?
I'd stick with the latter one, because the key is not directly associated with the config (often, you want to autogenerate keys in some way, but you don't want to mash the configName in there).
Another reason for this is that afaik the Cache API works the same way, and we should really keep it consistent.
On a side note, this doesn't solve the issue above - right? :)
I believe it will, actually, which is why I brought it up. ;-)
@daschl Agreed, it would appear that their is a collision between configurations if you specify more than one with the same name.
For the time being, I'm using the Session and Cookie storage classes from @farhadi https://github.com/farhadi/ali3/tree/master/storage
These just force the default adapters for Session to "default" and Cookie to "cookie". Seems to work fine for now.
Joining the conversation here. I do think it's unintuitive the way the session adapter operates on all configurations by default. I think removing that makes sense.
I feel like you should be able to set 'default' => true
in a configuration to get it to be the default. Then you could use 'true'
for the configuration name to get the default (similar to the Environment
and some other Adaptable classes). That would make sessions easier to work with across libraries/plugins.
Breaking the api is tough though. Session calls are littered all over the place. I could deal though.
I wonder if you could do it in a semi-polymorphous way to maintain backwards compatibility. i.e. Session::read("key")
gets a key from the default configuration, Session::read("config", "key")
gets from the named config, Session::read("key", array("name" => "cookie"))
would be backwards compatibility to naming a config, and then Session::read("config", "key", array("strategies" => false))
would be the new preferred way.
To @daschl's original problem... php session.name is the name of the cookie it sets to save the session_id. So you wind up with a cookie named 'app'
for the php session cookie. The cookie adapter will write cookies like 'app[someKey]'
-- but php's $_COOKIE array automatically converts cookies named 'app[someKey]'
into $_COOKIE['app']['someKey']
. So when the php session handler tries to read that cookie to get the session_id, it chokes on it being an array.
So unless Nate is thinking that cookies will get named something like 'configuration.name'
instead of just 'name'
, the conflict between naming php 'session.name'
and cookie adapter 'name'
isn't going to be fixed.
Has this been resolved?
Just ran into this issue ... so I don't think so @BlaineSch - investigating ...
investigation concluded ... the issue still persists when "cookie" configuration is added.
Also, heads up, anyone who faces the issue even after removing the cookie setting from Session configuration, you'd need to clear the cookies.
Now targeting 1.1. We will also need to change the API (in a BC way) of the Session class, forcing to be explicit about the configuration which gets used. Additionally the actual name of the cookie used for both Php and Cookie adapters will need to be generated in a more safe way to avoid name clashes.
There are already many changes in 1.0. Basically this works if configured correctly.
Hi all,
I've discovered a strange issue, maybe we can track it down together.
I have the following session config:
Now in my view, I check for login state:
And then I get the following error:
Interestingly, the line points to the
session_start()
call.If I remove the
Cookie
config and just leave the Php adapter in there, it works like a charm.I couldnt figure out where the conversion here is going on the first place, because settings like
session.name
are correctly formatted strings. Maybe the Auth adapter somewhere up the road is messing up with two configs?Here's the full stack trace: