• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

How can I get user id from session in javascript?

javascriptphpcodeigniter


PHP Snippet 1:

<input id="userId" value="<?php $_SESSION['user_id'] ?>" style="display:none">

PHP Snippet 2:

$( document ).ready(function() {
   alert( $('#userId').val() );
   console.log('done');
});

Related Snippets

Is there a way to use Foundry Model for Authentification inside Functional Tests?

Custom add to cart button URL for specific product in WooCommerce?

Why is this PHP array not the same?

Clients authentication and user authentication with laravel

Symfony there are no commands defined in the "make" namespace

Send POST data via raw JSON with Postman

PHP | "The requested PHP extension bcmath is missing from your system."

Filter array by skipping every nth element from the end

Custom Button next to “ADD TO CART” button of WooCommerce based on Product Type

Cannot pass null argument when using type hinting

unable to load your default controller on Codeigniter

Fatal error: Uncaught mysqli_sql_exception: Unknown database 'test' in ... (How do I fix that? Using PHP)

How to test laravel controller method?

PHP Deprecated issue when running artisan command

With doctrine ODM, can I embed many subdocuments in a main document?

About Contact Privacy policy Terms and conditions