• 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

How to submit the custom form data in database in WordPress without plugin using ajax?

Laravel MSSQL Server Connection not working

Symfony 4: "Autowire: you should configure its value explicitly."

Distribute array row data to make multiple new rows

How to set time with DateTime modify?

Symfony Make:Migration : The metadata storage is not up to date, please run the sync-metadata-storage command to fix this issue

Fatal error: [] operator not supported for strings

onKeyUp event calculation not working on the following rows from php generated forms except the first one

How to programmatically find public properties of a class from inside one of it's methods

laravel automatically deletes server.php on php artisan serve

Laravel UUID generation

Call to undefined function openssl_decrypt

Form Validation and Submission to database

Getting error: CodeIgniterDatabaseBaseResult::getResult in CodeIgniter

WHM Enabling mod_rewrite

About Contact Privacy policy Terms and conditions