Welcome Guest, Not a member yet? Register   Sign In
Dynamic CSS using session variables
#4

(This post was last modified: 11-21-2017, 06:28 PM by skunkbad.)

If you intend to use the CI session in your CSS, you'd have to route the requests through CI and load the session library. So, in your .htaccess file you'd rewrite the request to a controller/method that CI could route to, then you'd load the session library and output the CSS as a view. With the appropriate headers of course. Technically, if you have everything set up right you could use the CI session outside of CodeIgniter, but there's a lot going on in the session library, and it's likely you haven't configured your external session to be compatible with CI's session. One does not simply call session_start().

Another thing, and it would be an obstacle for you if trying to use the CI session outside of CodeIgniter, is that CodeIgniter uses a session handler that prepends the session name to the file path, and unless you replicate this functionality, you'd never have success retrieving, using, or working with a session created in CI. It's certainly something you could do, but you'd end up creating a library outside of CodeIgniter that was more or less a copy of what CodeIgniter is using. What I'm talking about is this:

CodeIgniter creates a session and the session file is named:

ci_session209385023850293850928309528

You try to access the session outside of CodeIgniter, but your session file is named:

sess209385023850293850928309528

A MUCH easier solution for you would be to use a simple cookie for this CSS related value. You don't need the session for everything under the sun.
Reply


Messages In This Thread
RE: Dynamic CSS using session variables - by skunkbad - 11-21-2017, 05:36 PM



Theme © iAndrew 2016 - Forum software by © MyBB