anp241 Posted March 16, 2015 Share Posted March 16, 2015 Hello, I cannot set the session variable in PHP code after setting php_flag session.cookie_secure on in .htaccess file. What other setting I have to do, so that I can set the session variables values. Thanks Regards Anoop Quote Link to comment Share on other sites More sharing options...
joel24 Posted March 16, 2015 Share Posted March 16, 2015 you need to run the PHP command to initiate a session. session_start(); http://php.net/manual/en/function.session-start.php Quote Link to comment Share on other sites More sharing options...
ginerjm Posted March 16, 2015 Share Posted March 16, 2015 Is there some reason you are making that setting in you htaccess file? It's not technically needed to do what your post title suggests. To set a session var you simply assign a value to it just as you would for any php variable. Of course, as Joel states, you have to first start the php 'session' with the session_start() command. Place this at the top of all of your scripts as a habit so that you always have access to it. <?php session_start(); .. .. .. $_SESSION['myvar'] = "this value"; .. .. That's all there is to it. There are other things that come into play when you are being extremely security conscious or need to do some kinds of deception, but for your defined needs this is all you need. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.