• 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

MySQL order by field in Eloquent

woocommerce change position of price

Laravel Sanctum CSRF not authenticating

Laravel database insert with combining array and string

Laravel - How to properly generate unique slugs from article titles?

NGINX: connect() to unix:/var/run/php7.2-fpm.sock failed (2: No such file or directory)

Lumen - Postgresql setup - Composer

str_word_count() function doesn't display Arabic language properly

How to add a custom field to all Woocommerce attribute terms using add_action

Issue saving card for customer

Converting alphabet letter to alphabet position in PHP [duplicate]

PHP 8.1: strftime() is deprecated

Can't exclude directories from .htaccess mobile redirect?

PHP echo values of all sub keys [duplicate]

Where do I need to place a hook for phpunit?

About Contact Privacy policy Terms and conditions