• 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

Form repeater send wrong data with last element in Laravel

Reading input in php from terminal

Get keys from associative array [duplicate]

MISSING UPDATES FOR: MEDIA Drupal 9

Wordpress wpdb->delete issue

Webscraping Symfony/Panther: Can't get HTML

How to identify whether webp image is static or animated?

Redis Command To Sort Keys

PHPExcel_IOFactory::createWriter causes wrong behaviour

Xdebug can't connect back to Docker host

how to hide previous markers when new markers added in google map javascript api

"Unable to load dynamic library 'pdo_sqlsrv.so' "Cenos7 PHP7.2.10

how to retrieve the first and last instance of a row in pdo dataset

How to auto populate preferredCountries from intl-tel-input with db output

Woocommerce Checkout - Add conditional field required if one field is filled

About Contact Privacy policy Terms and conditions