• 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

Sum column values from multiple arrays

Two buttons one form

Transpose multidimensional array and join values with commas

Why "Class 'GuzzleHttpClient' not found" even after Installing it in Laravel?

How to convert time from one timezone to another in PHP

SQL AVG() to 2 decimals

Why do I have invalid argument supply for foreach in Laravel for json response? [duplicate]

How to disable only_full_group_by option in Laravel

How can I solve "laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system"?

XML to CSV with PHP converter [problem with images grabing]

php curl_exec() Connection refused when retrieving a remote image

PHP DOTENV unable to load env vars

Pagekite error: FAIL: localhost:8080 is down

PHP to search within txt file and echo the whole line

Laravel csrf token mismatch for ajax POST Request

About Contact Privacy policy Terms and conditions