My elgg installation allows a user to create separate spaces and to use objects within each space independently. A new object should use the space as its default container. I think I would like to set the space in the session variable and retrieve it using a function. Unfortunately, I don't know how.
Can you tell me how to set the space in the session and retrieve it using a (new) function like "get_current_space()"? I don't know how I should do either of those things.
Maybe there's a better way? I'm certainly open to recommendations.
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Jerome Bakker@jeabakker

Jerome Bakker - 0 likes
- C0Rrupt@thjMMvw

C0Rrupt - 0 likes
- iionly@iionly

iionly - 0 likes
- C0Rrupt@thjMMvw

C0Rrupt - 0 likes
- Nikolai Shcherbin@rivervanrain

Nikolai Shcherbin - 1 like
You must log in to post replies.You can retrieve the current session of the user by calling `elgg_get_session()` this will result in an \ElggSession object.
You can set any value you wish by doing the following
To use the stored variable simply use
Hope this helps
"Session" might not be what I was looking for. Elgg's session object does not seem to store the current_space_id for AMD requests between page refreshes. Is there a way to store the variable more persistently? Would using a JSON object be advisable? I need good advice as much as I do answers.
I don't know enough to know if there's any way to save a session id persistently over AMD requests.
What about using cookies? Would that be a possibility to save a session id on the client side to identify the session?
I considered cookies, but I don't think they're as reliable as I would like. People can disable cookies in their browser. Isn't the JSON option like server-side cookies? I went this route and it seems to be working. An added bonus is being able to persist across sessions so one can resume in the space that one left last time.
Are there concerns about using the JSON approach? It seems pretty secure, but I'm not a student of security best- practices.
@C0Rrupt Use Web services