Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8294533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:14:59+00:00 2026-06-08T14:14:59+00:00

In my website I set some values to session object like user_status, user_name and

  • 0

In my website I set some values to session object like “user_status”, “user_name” and like so. The php file looks like this:

<script type="text/javascript">
    var logged = <? echo $this->session->getValueOf("user_status"); ?>;
</script>

<a class="show_message" href="#">SHow my status</a>

Well, I have a js script that pretends do an action according to user status in the website, so, I have this:

$('.show_status').click(function(event){

    //ask for user status
    if (logged){
        //do something
    }
    else{
        //do another action for visitors
    }
});

Walking around I thought if it is the best way flow data between session -> javascript, because if you inspect the page source at browser the value of user_status will be visible and could be riskable for website security.

Thanks in advance

EDIT:

  1. logged var only takes a boolean value.
  2. The js action must be executed each time the element #(".show_status") is clicked.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T14:15:00+00:00Added an answer on June 8, 2026 at 2:15 pm

    If the JavaScript is just being used for interface stuff, and doesn’t have any back end effects, I probably wouldn’t worry too much about the insecurity of handling that logic client-side.

    If security is an important thing though, I would recommend you use PHP to write the appropriate JavaScript function. For example:

    On the page being viewed, perhaps in the header, you have:

    <script type="text/javascript">
        <?php
        if ($this->session->getValueOf("user_status")) {
            require_once('logged_in_user_functions.js');
        } else {
            require_once('visitor_functions.js');
        }
        ?>
    </script>
    

    In the file `logged_in_user_functions.js’ you have:

    function showComment(id) {
        //logic that shows the comment here
    }
    
    function showCommentSubmissionForm() {
        //logic that adds this form to the page goes here
    }
    

    Meanwhile, in the file `visitor_functions.js’ you have:

    function showComment(id) {
        //logic that shows the comment in a different way goes here
    }
    
    function showCommentSubmissionForm() {
        //logic to display a message saying the user needs to log in to post a comment goes here
    }
    

    Then you can add your logic into your page without having to check the user status. The proper behaviour is provided by virtue of which .js file was included:

    <button id='add_comment_button' onclick='showCommentSubmissionForm()'>Add Comment</button>
    

    This gives PHP (and thus the server, not the client) final say in what gets displayed to the user.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm automating ie from within Excel VBA like this, in part Set ie =
I have an ASP.NET website set up, and I'm using Google Analytics for page
I have just added a google translate in website.And set the default language English.
In IIS 5.1, i have set the website security to Basic Authentications and i
I have set up my website to use ASP.NET Membership. it all works fine
I have set up a website here: http://liamwli.co.uk/ggsim On the bottom, there are 2
I have gotta website powered by a set of jQueries; Dynamically loading the contents
I have a website setup in IIS with one web.config set at the root
I am developing a website in which a cookie is set when the user
How do I set the HTTP custom error messages on a website installed by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.