• 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

Passing PHP JSON to Javascript: echo json_encode vs echo json declaration

Elasticsearch - Want to sort by field in all indices where that particular field available or not if not then avoid it

MISSING UPDATES FOR: MEDIA Drupal 9

Cannot connect to own websocket server when on secured domain

Performance of foreach, array_map with lambda and array_map with static function

Execute only one time and then wait set period of time before executing again

Symfony process run throws exception - executing on command line works

How to override htaccees file for cache control header

MySQL default time format UTC or GMT?

How to get the total hour from starting time to end time in php

PHP: How to raise number to (tiny) fractional exponent?

Get data from accuweather api url

Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables 11 [closed]

Form repeater send wrong data with last element in Laravel

Additional price based on cart item count in WooCommerce

About Contact Privacy policy Terms and conditions